Skip to content

Commit

Permalink
[16.0][IMP] Merging page in mrp_bom form view, adding custom fields
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinDupont committed Nov 21, 2024
1 parent 4657f27 commit 95285bd
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fermente_mrp/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@
"author": "GRAP",
"website": "https://github.com/grap/grap-odoo-custom",
"license": "AGPL-3",
"depends": ["mrp"],
"depends": [
"mrp",
# OCA
"web_widget_numeric_step",
"mrp_bom_widget_section_and_note_one2many",
# GRAP
"mrp_bom_tag",
"mrp_bom_line_net_qty",
],
"data": [
"security/ir.model.access.csv",
"views/view_mrp_bom.xml",
],
}
4 changes: 4 additions & 0 deletions fermente_mrp/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Customize Odoo / odoo / ``mrp`` module.
**Access Rights**

* Allow members of ``mrp.group_mrp_user`` to create ``mrp.bom`` and ``mrp.bom.line``.

**Views**

* Create custom view : adding custom ``mrp.bom.line`` fields to ``mrp.bom`` form view in page ``Components and sections``
92 changes: 92 additions & 0 deletions fermente_mrp/views/view_mrp_bom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
@author: Quentin DUPONT (quentin.dupont@grap.coop)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>

<!-- ************************************************************ -->
<!-- MRP Bill of Materials - Form -->
<!-- ************************************************************ -->

<record id="view_mrp_business_bom_form" model="ir.ui.view">
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp_bom_widget_section_and_note_one2many.mrp_bom_form_view_section" />
<field name="arch" type="xml">

<!-- Hide fields -->

<xpath expr="//field[@name='bom_line_with_sectionnote_ids']/tree/button[@name='action_see_attachments']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>

<xpath expr="//field[@name='bom_line_with_sectionnote_ids']/tree/field[@name='attachments_count']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>

<!-- Add fields -->
<xpath
expr="//field[@name='bom_line_with_sectionnote_ids']/tree/field[@name='product_uom_id']"
position="before"
>
<!-- mrp_bom_line_net_qty fields -->
<field name="diff_product_qty_gross_net" invisible="1" />
<button
name="set_product_qty_gross"
icon="fa-arrow-left"
type="object"
attrs="{'invisible': [('diff_product_qty_gross_net', '=', 0)]}"
title="This will set product gross quantity with net quantity and loss percentage"
/>
<field
name="loss_percentage"
widget="numeric_step"
options="{'step': 1}"
/>
<button
name="set_product_qty_net"
icon="fa-arrow-right"
type="object"
attrs="{'invisible': [('diff_product_qty_gross_net', '=', 0)]}"
title="This will set product net quantity with gross quantity and loss percentage"
/>
<field name="product_qty_net" />

<!-- mrp_bom_product_price_margin fields -->
<field name="currency_id" invisible="1" />
<field name="standard_price_unit" widget="monetary" />
<field
name="standard_price_subtotal"
readonly="1"
sum="Total"
widget="monetary"
/>
<field
name="standard_price_subtotal_percentage"
string="ST %"
widget="percentage"
/>
</xpath>

<!-- Add decoration -->
<xpath expr="//field[@name='bom_line_with_sectionnote_ids']/tree" position="attributes">>
<attribute
name="decoration-warning"
>diff_product_qty_gross_net != 0</attribute>
</xpath>

<!-- Rename page -->
<xpath expr="//page[@name='components_w_sections_notes']" position="attributes">
<attribute name="string">Components</attribute>
</xpath>

<!-- Hide page -->
<xpath expr="//page[@name='components']" position="attributes">
<attribute name="groups">base.group_no_one</attribute>
</xpath>

</field>
</record>

</odoo>

0 comments on commit 95285bd

Please sign in to comment.