Skip to content

Commit

Permalink
[14.0][IMP] custom_mrp_descarga: Change quartering compute function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tu Nombre committed Jul 9, 2024
1 parent afa50b4 commit 191a46b
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 25 deletions.
1 change: 0 additions & 1 deletion custom_mrp_descarga/data/ir_sequence.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<record id="quartering_sequence" model="ir.sequence">
<field name="name">Secuencia para órdenes de producción de despiece</field>
Expand Down
1 change: 0 additions & 1 deletion custom_mrp_descarga/data/mrp_bom_category.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<record id="quartering_category" model="mrp.bom.category">
<field name="name">Despiece</field>
Expand Down
1 change: 0 additions & 1 deletion custom_mrp_descarga/data/quartering_product.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<record id="quartering_product" model="product.product">
<field name="name">Despiece</field>
Expand Down
6 changes: 4 additions & 2 deletions custom_mrp_descarga/models/mrp_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ def _compute_quartering(self):
for line in self:
quartering = False
try:
quartering = self.env.ref("custom_mrp_descarga.quartering_category")
if line.category_id == quartering:
quartering_type = self.env.ref(
"custom_mrp_descarga.quartering_category"
)
if line.category_id == quartering_type:
quartering = True
except Exception:
quartering = False
Expand Down
11 changes: 11 additions & 0 deletions custom_mrp_descarga/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,15 @@ def write(self, values):
if line.move_id.state == "cancel" and values.get("qty_done") != 0:
line.move_id.state = "done"
line.state = "done"
if "qty_done" or "amount" or "state" in values:
for line in self:
if line.lot_id and line.company_id.paasa:
quartering = line.lot_id.move_line_ids.filtered(
lambda c: c.production_id
and c.production_id.quartering
and (c.location_id == c.production_id.location_src_id)
)
for record in quartering:
if record.standard_price != line.lot_id.average_price:
record.standard_price = line.lot_id.average_price
return result
9 changes: 0 additions & 9 deletions custom_mrp_descarga/models/stock_production_lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,12 @@ def _compute_average_price(self):
clasified = line.move_line_ids.filtered(
lambda c: c.state == "done" and (c.location_dest_id.usage == "internal")
)
quartering = line.move_line_ids.filtered(
lambda c: c.production_id
and c.production_id.quartering
and (c.location_id == c.production_id.location_src_id)
)
if clasified:
amount_total = sum(clasified.mapped("amount"))
qty_done = sum(clasified.mapped("qty_done"))
if qty_done != 0:
average_price = amount_total / qty_done
line.average_price = average_price
if line.company_id.paasa and average_price:
for record in quartering:
if record.standard_price != line.average_price:
record.standard_price = line.average_price

def action_view_move_lines(self):
context = self.env.context.copy()
Expand Down
2 changes: 1 addition & 1 deletion custom_mrp_descarga/views/mrp_bom_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<field name="inherit_id" ref="mrp.mrp_bom_form_view" />
<field name="arch" type="xml">
<field name="code" position="after">
<field name="quartering" invisible="1" />
<field name="quartering" />
<field name="no_duplicate_lines" />
<field name="no_produce_product" />
</field>
Expand Down
12 changes: 8 additions & 4 deletions custom_mrp_descarga/views/mrp_production_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@
<record id="view_mrp_production_filter_lot" model="ir.ui.view">
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.view_mrp_production_filter" />
<field name="priority" eval="100" />
<field name="mode">primary</field>
<field name="arch" type="xml">
<field name="lot_producing_id" position="replace">
<field name="lot_producing_id" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name="lot_producing_id" position="after">
<field
name="lot_producing_id"
filter_domain="[('lot_producing_id','=ilike',str(self)+'%')]"
Expand All @@ -115,7 +117,6 @@
<record id="mrp_production_form_view" model="ir.ui.view">
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp_production_date.mrp_production_form_view" />
<field name="priority" eval="100" />
<field name="arch" type="xml">
<header position="inside">
<button
Expand Down Expand Up @@ -354,7 +355,10 @@
attrs="{'invisible':[('saca_id', '=', False)], 'readonly': [('state', 'in', ('cancel', 'done'))]}"
/>
</field>
<field name="production_date" position="replace">
<field name="production_date" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name="production_date" position="after">
<label
for="production_date"
attrs="{'invisible':[('chick_production', '=', False)]}"
Expand Down
11 changes: 5 additions & 6 deletions custom_mrp_descarga/views/stock_move_line_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,13 @@
<field name="name">stock.move.line.search.view</field>
<field name="model">stock.move.line</field>
<field name="mode">primary</field>
<field name="priority">100</field>
<field name="priority">30</field>
<field name="inherit_id" ref="stock.stock_move_line_view_search" />
<field name="arch" type="xml">
<field name="lot_id" position="replace">
<field
name="lot_id"
filter_domain="[('lot_id','=ilike',str(self)+'%')]"
/>
<field name="lot_id" position="attributes">
<attribute
name="filter_domain"
>[('lot_id','=ilike',str(self)+'%')]</attribute>
</field>
</field>
</record>
Expand Down

0 comments on commit 191a46b

Please sign in to comment.