Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][IMP] custom_mrp_descarga: Change reader function. #492

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion custom_mrp_descarga/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ class StockMoveLine(models.Model):
)
average_price = fields.Float(string="Average Price", related="lot_id.average_price")

@api.depends(
"product_id", "picking_type_use_create_lots", "lot_id.expiration_date", "reader"
)
def _compute_expiration_date(self):
for move_line in self:
if (
move_line.reader
and len(move_line.reader) == 44
and move_line.reader[16] == "1"
and (move_line.reader[17]) == "5"
):
return True
else:
return super()._compute_expiration_date()

@api.depends("production_id")
def _compute_sequence(self):
for line in self:
Expand Down Expand Up @@ -120,11 +135,15 @@ def reader_44_15(self, reader):
)
self.write(
{
"expiration_date": expiration_date,
"qty_done": qty_done,
"lot_id": lot.id,
}
)
self.write(
{
"expiration_date": expiration_date,
}
)

def reader_46_31(self, reader):
self.ensure_one()
Expand Down
31 changes: 29 additions & 2 deletions custom_mrp_descarga/views/stock_move_line_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,32 @@
</field>
</record>

<record id="view_stock_move_line_detailed_operation_tree" model="ir.ui.view">
<field name="model">stock.move.line</field>
<field
name="inherit_id"
ref="stock_move_line_product_lot_reader.view_stock_move_line_detailed_operation_tree"
/>
<field name="arch" type="xml">
<field name="reader" position="attributes">
<attribute name="optional">hide</attribute>
</field>
</field>
</record>

<record id="view_move_line_tree_mrp" model="ir.ui.view">
<field name="model">stock.move.line</field>
<field name="inherit_id" ref="stock.view_move_line_tree" />
<field name="mode">primary</field>
<field name="arch" type="xml">
<field name="qty_done" position="attributes">
<attribute
name="attrs"
>{'readonly': [('state', 'in', ('cancel'))]}</attribute>
</field>
</field>
</record>

<record id="production_finished_move_line_ids_tree_view" model="ir.ui.view">
<field name="model">stock.move.line</field>
<field
Expand All @@ -47,7 +73,7 @@
<field
name="reader"
attrs="{'readonly': ('state', 'in', ('done', 'cancel'))}"
optional="show"
optional="hide"
/>
</field>
<field name="qty_done" position="after">
Expand All @@ -72,7 +98,7 @@
<field
name="reader"
attrs="{'readonly': ('state', 'in', ('done', 'cancel'))}"
optional="show"
optional="hide"
/>
<field name="expiration_date" optional="hide" force_save="1" />
</field>
Expand Down Expand Up @@ -293,5 +319,6 @@

<record id="mrp.action_mrp_production_moves" model="ir.actions.act_window">
<field name="view_mode">tree,form,pivot</field>
<field name="view_id" ref="view_move_line_tree_mrp" />
</record>
</odoo>
Loading