Skip to content

Commit

Permalink
[FIX] plm_auto_engcode sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
jayraj-omnia committed Jan 10, 2025
1 parent 96ca508 commit 57899fd
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 10 deletions.
15 changes: 9 additions & 6 deletions plm/views/product_product.xml
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,15 @@
<xpath expr="//notebook[last()]" position="before">
<field name="is_engcode_editable" invisible="1"/>
<group>
<group colspan="4" col="3" string="OdooPLM Information">
<field name="engineering_code"
readonly="is_engcode_editable==False"/>
<field name="engineering_revision"
nolabel="1"
readonly="is_engcode_editable==False"/>
<group colspan="4" string="OdooPLM Information">
<label for="engineering_code"/>
<div>
<field name="engineering_code" class="oe_inline"
readonly="is_engcode_editable==False"/> - Rev_
<field name="engineering_revision"
nolabel="1" class="oe_inline"
readonly="is_engcode_editable==False"/>
</div>
</group>
<group colspan="4">
<field name="std_description"
Expand Down
6 changes: 5 additions & 1 deletion plm_auto_engcode/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
""",
"license": "AGPL-3",
"depends": ["plm"],
"data": ["data/ir_sequence.xml", "views/product_category.xml"],
"data": [
"data/ir_sequence.xml",
"views/product_category.xml",
"views/product_product.xml"
],
"installable": True,
"application": False,
"auto_install": False,
Expand Down
12 changes: 10 additions & 2 deletions plm_auto_engcode/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ def _getNewCode(self):
"""
if self.env.context.get("odooPLM", False):
if self.categ_id and self.categ_id.plm_code_sequence:
return self.categ_id.plm_code_sequence.next_by_id()
return self.env["ir.sequence"].next_by_code("plm.eng.code")
if self.old_plm_code_sequence_id.id != self.categ_id.plm_code_sequence.id:
self.old_plm_code_sequence_id = self.categ_id.plm_code_sequence.id
return self.categ_id.plm_code_sequence.next_by_id()
elif self.old_plm_code_sequence_id.id == self.categ_id.plm_code_sequence.id:
return self.engineering_code

else:
self.old_plm_code_sequence_id = False
return self.env["ir.sequence"].next_by_code("plm.eng.code")
return False

engineering_code = fields.Char(
Expand All @@ -61,3 +68,4 @@ def _getNewCode(self):
),
size=64,
)
old_plm_code_sequence_id = fields.Many2one('ir.sequence')
11 changes: 11 additions & 0 deletions plm_auto_engcode/views/product_category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,15 @@
</field>
</field>
</record>

<record id="view_product_product_form_old_plm_code_sequence_id" model="ir.ui.view">
<field name="name">product.product.form.plm_code_sequence_id</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<field name="engineering_code" position="after">
<field name="old_plm_code_sequence_id" invisible="1"/>
</field>
</field>
</record>
</odoo>
13 changes: 13 additions & 0 deletions plm_auto_engcode/views/product_product.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_product_product_form_old_plm_code_sequence_id" model="ir.ui.view">
<field name="name">product.product.form.plm_code_sequence_id</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<field name="engineering_code" position="after">
<field name="old_plm_code_sequence_id" invisible="1"/>
</field>
</field>
</record>
</odoo>
2 changes: 2 additions & 0 deletions plm_auto_internalref/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def computeDefaultCode(self, vals={}, objBrowse=None):
out = self.getDefaultCodeTemplate % (engineering_code, engineering_revision)
if default_code == out:
return False
if default_code:
out = f"{engineering_code}_{engineering_revision}"
return out

def write(self, vals):
Expand Down
6 changes: 5 additions & 1 deletion plm_automated_convertion/view/ir_attachment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
<xpath expr="//field[@name='is_plm']" position="before">
<field name="is_converted_document" groups="base.group_no_one"/>
<field name="source_convert_document" readonly="True"/>
<field name="converted_documents" readonly="True"/>
</xpath>
<xpath expr="//notebook" position="inside">
<page string="Converted Documents">
<field name="converted_documents" readonly="True"/>
</page>
</xpath>
</field>
</record>
Expand Down

0 comments on commit 57899fd

Please sign in to comment.