Skip to content

Commit

Permalink
[WIP][REF] mrp_business description fields -> mrp_bom_note
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinDupont committed Mar 14, 2024
1 parent df6bb6d commit 528bdff
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 26 deletions.
11 changes: 5 additions & 6 deletions grap_change_views_mrp/views/view_mrp_bom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
type="object" class="oe_link"
attrs="{'invisible': [('tla_to_change', '=', False)]}"/>
</div>
<field name="description_short"/>
<field name="description_long"/>
<!-- / mrp_business -->
<!-- mrp_bom_tag -->
<field name="bom_tag_ids" widget="many2many_tags" string="Tags 🎨"
Expand Down Expand Up @@ -257,6 +255,11 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
</tree>
</field>
</page>
<page string="Notes">
<group>
<field name="notes" nolabel="1"/>
</group>
</page>
<page string="Miscellaneous" groups="base.group_no_one">
<group>
<group>
Expand Down Expand Up @@ -307,7 +310,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<field name="product_uom_id" string="UoM" groups="uom.group_uom"/>
<field name="routing_id" groups="mrp.group_mrp_routings"/>
<!-- mrp_business and mrp_bom_tag-->
<field name="description_short"/>
<field name="bom_tag_ids" widget="many2many_tags" options="{'color_field': 'color'}"/>
<field name="priority" widget="priority"/>
<field name="time_to_produce"/>
Expand Down Expand Up @@ -341,7 +343,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<field name="product_uom_id" string="UoM" groups="uom.group_uom"/>
<field name="routing_id" groups="mrp.group_mrp_routings"/>
<!-- mrp_business and mrp_bom_tag-->
<field name="description_short"/>
<field name="bom_tag_ids" widget="many2many_tags" options="{'color_field': 'color'}"/>
<field name="priority" widget="priority"/>
<field name="time_to_produce"/>
Expand Down Expand Up @@ -372,7 +373,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<field name="product_id" string="Product"/>
<field name="product_uom_id" string="UoM" groups="uom.group_uom"/>
<!-- mrp_business and mrp_bom_tag-->
<field name="description_short"/>
<field name="priority" widget="priority"/>
<!-- mrp_bom_sale_product_margin -->
<field name="diff_product_bom_standard_price" string="Diff BoM and Product" groups="base.group_no_one"/>
Expand All @@ -394,7 +394,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<field name="product_id" string="Product"/>
<field name="product_uom_id" string="UoM" groups="uom.group_uom"/>
<!-- mrp_business and mrp_bom_tag-->
<field name="description_short"/>
<field name="priority" widget="priority"/>
<!-- mrp_bom_sale_product_margin -->
<field name="diff_product_bom_standard_price" string="Diff BoM and Product" groups="base.group_no_one"/>
Expand Down
2 changes: 2 additions & 0 deletions mrp_bom_purchase/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# GRAP
"mrp_business",
"mrp_bom_sale_product_margin",
# OCA
"mrp_bom_note",
],
"data": [
"data/report_paperformat.xml",
Expand Down
3 changes: 1 addition & 2 deletions mrp_bom_purchase/report/report_bom_purchase_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,7 @@ def _prepare_data_to_manufacture(self, data):
round(wiz_bom.bom_id.standard_price_total, 3),
round(wiz_bom.wizard_line_subtotal, 3),
tmp_bom_lines,
bom.description_short,
bom.description_long,
bom.notes,
bom.description_packaging,
]
)
Expand Down
15 changes: 6 additions & 9 deletions mrp_bom_purchase/report/report_bom_purchase_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,16 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<div class="page small-font-size" style="page-break-before:always;">
<span>Bill of Material</span>
<h3 class="title-h3"><b><span t-esc="manufacture_bom[0]"/></b></h3>
<t t-if="manufacture_bom[6]">
<br/><span class="bom-description"><b>Short description: </b><span t-esc="manufacture_bom[6]"/></span>
</t>
<t t-if="manufacture_bom[7]">
<br/><span class="bom-description"><b>Long description: </b><span t-esc="manufacture_bom[7]"/></span>
<br/><br/>
</t>
<h6>
<span class="bom-desired-quantity"><b>Quantity: </b><span t-esc="manufacture_bom[1]"/> <span t-esc="manufacture_bom[2]"/></span>
<t t-if="manufacture_bom[8]">
- <span t-esc="manufacture_bom[8]"/>
<t t-if="manufacture_bom[7]">
- <span t-esc="manufacture_bom[7]"/>
</t>
</h6>
<t t-if="manufacture_bom[6]">
<h6><br/><span class="bom-description"><b>Notes</b></span></h6>
<span t-raw="manufacture_bom[6]"/>
</t>
<br/>
<table class="table table-sm table-bordered">
<thead>
Expand Down
2 changes: 1 addition & 1 deletion mrp_bom_purchase/wizard/bom_print_purchase_list_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _default_line_ids(self):
"currency_id": bom.currency_id,
"bom_uom_id": bom.product_uom_id,
"bom_origin": bom_and_quantity["bom_origin"],
"bom_description": bom.description_short,
"bom_description": bom.description_packaging,
"bom_product_qty": bom.product_qty,
"quantity": bom_and_quantity["bom_qty"],
# standard_price_total is already divide for product unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class BomPrintPurchaseListWizardLine(models.TransientModel):
compute="_compute_wizard_line_subtotal",
)

@api.depends("bom_id")
@api.depends("bom_id.description_packaging")
def _compute_bom_description(self):
for line in self.filtered(lambda x: x.bom_id):
line.bom_description = line.bom_id.description_short
line.bom_description = line.bom_id.description_packaging

@api.depends("bom_id", "quantity")
def _compute_wizard_line_subtotal(self):
Expand Down
2 changes: 1 addition & 1 deletion mrp_business/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "MRP Business Modules",
"summary": "MRP functions that meet the business needs of GRAP,"
"adapted for food-related professions",
"version": "12.0.1.3.0",
"version": "12.0.1.4.0",
"category": "GRAP - Custom",
"author": "GRAP",
"website": "https://github.com/grap/grap-odoo-custom",
Expand Down
30 changes: 30 additions & 0 deletions mrp_business/migrations/12.0.1.4.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
# @author: Quentin Dupont
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging

from openupgradelib import openupgrade

_logger = logging.getLogger(__name__)


@openupgrade.migrate()
def migrate(cr, env, version):
_logger.info("Migrate mrp_business description fields to mrp_bom_note field notes")

if not openupgrade.column_exists(env.cr, "mrp_bom", "notes"):
_logger.info("If mrp_bom_note was not installed, create column")
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE mrp_bom
ADD COLUMN notes text;
""",
)

cr.execute(
"""
UPDATE mrp_bom
SET notes = '<p>' || description_short || '<br/>' || description_long || '</p>';
"""
)
2 changes: 0 additions & 2 deletions mrp_business/models/mrp_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class MrpBom(models.Model):
# ========== Divers
currency_id = fields.Many2one(related="product_tmpl_id.currency_id")
description_packaging = fields.Char(string="Packaging description")
description_short = fields.Char(string="Short description")
description_long = fields.Text(string="Long description")
# Tracking not possible for One2many
# bom_line_ids = fields.One2many(track_visibility="onchange")
priority = fields.Selection(
Expand Down
3 changes: 0 additions & 3 deletions mrp_business/views/view_mrp_bom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
type="object" class="oe_link"
attrs="{'invisible': [('tla_to_change', '=', False)]}"/>
</div>
<field name="description_short"/>
<field name="description_long"/>
</xpath>

<xpath expr="//field[@name='ready_to_produce']/../..//field[@name='sequence']" position="before">
Expand All @@ -60,7 +58,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<field name="inherit_id" ref="mrp.mrp_bom_tree_view" />
<field name="arch" type="xml">
<xpath expr="//field[@name='product_id']" position="after">
<field name="description_short"/>
<field name="priority" widget="priority"/>
<field name="time_to_produce"/>
</xpath>
Expand Down

0 comments on commit 528bdff

Please sign in to comment.