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 5, 2024
1 parent afa50b4 commit 40d0ca3
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 231 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
13 changes: 12 additions & 1 deletion custom_mrp_descarga/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class StockMoveLine(models.Model):
string="Sequence", compute="_compute_sequence", store=True
)
quartering = fields.Boolean(
string="Quartering", related="production_id.quartering", store=True
string="Sequence", compute="_compute_sequence", store=True
)
saca_date = fields.Date(string="Saca Date", related="saca_line_id.date", store=True)

Expand Down 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
6 changes: 3 additions & 3 deletions custom_mrp_descarga/views/product_template_view.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="product_template_form_view" model="ir.ui.view">
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view" />
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<group name="group_general" position="inside">
<field name="download_product" />
<field name="download_product"/>
</group>
</field>
</record>
Expand Down
35 changes: 10 additions & 25 deletions custom_mrp_descarga/views/saca_line_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,24 @@
<odoo>
<record id="saca_line_form_view" model="ir.ui.view">
<field name="model">saca.line</field>
<field name="inherit_id" ref="custom_saca.saca_line_form_view" />
<field name="inherit_id" ref="custom_saca.saca_line_form_view"/>
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button
class="oe_stat_button"
icon="fa-wrench"
type="object"
name="action_view_production"
attrs="{'invisible': [('count_production', '=', 0)]}"
>
<field
string="Production Orders"
name="count_production"
widget="statinfo"
/>
<button class="oe_stat_button" icon="fa-wrench" type="object" name="action_view_production" attrs="{'invisible': [('count_production', '=', 0)]}">
<field string="Production Orders" name="count_production" widget="statinfo"/>
</button>
</div>
<xpath expr="//page[@name='classified']" position="inside">
<group string="Deconstruction">
<field name="production_ids" nolabel="1">
<tree>
<field name="name" />
<field name="date_planned_start" widget="remaining_days" />
<field name="product_id" />
<field name="product_qty" />
<field name="product_uom_id" />
<field name="company_id" />
<field
name="state"
widget="badge"
decoration-success="state == 'done'"
decoration-info="state not in ('done', 'cancel')"
/>
<field name="name"/>
<field name="date_planned_start" widget="remaining_days"/>
<field name="product_id"/>
<field name="product_qty"/>
<field name="product_uom_id"/>
<field name="company_id"/>
<field name="state" widget="badge" decoration-success="state == 'done'" decoration-info="state not in ('done', 'cancel')"/>
</tree>
</field>
</group>
Expand Down
Loading

0 comments on commit 40d0ca3

Please sign in to comment.