Skip to content

Commit

Permalink
IMP: layout and fix translation recovery with null product
Browse files Browse the repository at this point in the history
  • Loading branch information
mboscolo committed Sep 24, 2024
1 parent a45d576 commit 89dc3b9
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 62 deletions.
2 changes: 1 addition & 1 deletion plm/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
##############################################################################
{
"name": "Product Lifecycle Management",
"version": "17.0.0.4",
"version": "17.0.0.5",
"author": "OmniaSolutions",
"website": "https://odooplm.omniasolutions.website",
"category": "Manufacturing/Product Lifecycle Management (PLM)",
Expand Down
11 changes: 6 additions & 5 deletions plm/models/plm_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,12 @@ def get_all_translation(self, object_id, fields):
get all field translated in all available languages
"""
out = {}
obj = self.env[self._name].browse([object_id])
for field_name in fields:
for code in self.env['res.lang'].search([('active','=', True)]).mapped("code"):
propKey = f"{field_name}@-@-@{code}"
out[propKey] = getattr(obj.with_context(lang=code), field_name)
obj = self.env[self._name].search([('id','=',object_id)])
if obj:
for field_name in fields:
for code in self.env['res.lang'].search([('active','=', True)]).mapped("code"):
propKey = f"{field_name}@-@-@{code}"
out[propKey] = getattr(obj.with_context(lang=code), field_name)
return out


Expand Down
4 changes: 2 additions & 2 deletions plm/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class ProductProduct(models.Model):
_inherit = ['product.product']
_description ="Product Product"

def onchange(self, values, field_name, field_onchange):
def onchange(self, values, field_names, fields_spec):
values = self.plm_sanitize(values)
if 'product_tmpl_id' in values:
del values['product_tmpl_id']
return super(ProductProduct, self).onchange(values, field_name, field_onchange)
return super(ProductProduct, self).onchange(values, field_names, fields_spec)

def action_show_reference(self):
localCtx = self.env.context.copy()
Expand Down
113 changes: 59 additions & 54 deletions plm/views/product_product.xml
Original file line number Diff line number Diff line change
Expand Up @@ -325,68 +325,73 @@
<xpath expr="//notebook[last()]" position="before">
<field name="is_engcode_editable" invisible="1"/>
<group>
<group>
<field name="engineering_code"
readonly="is_engcode_editable==False"/>
</group>
<group>
<field name="engineering_revision"
readonly="is_engcode_editable==False"/>
</group>
</group>
<group>
<group>
<group colpsan="3" col="3">
<field name="std_description"
colspan="4"
readonly="engineering_state in ['released','obsoleted']"/>
<separator colspan="3" string="" invisible="1"/>
<field name="show_std_field1" invisible="1" colspan="1"/>
<field name="show_std_field2" invisible="1" colspan="1"/>
<field name="show_std_field3" invisible="1" colspan="1"/>
<field name="readonly_std_umc1" invisible="1" colspan="1"/>
<field name="readonly_std_umc2" invisible="1" colspan="1"/>
<field name="readonly_std_umc3" invisible="1" colspan="1"/>
<separator colspan="3" string="" invisible="1"/>
</group>
</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>
<group colspan="4">
<field name="std_description"
readonly="engineering_state in ['released','obsoleted']"/>
</group>
<group colspan="4">
<field name="show_std_field1" invisible="1"/>
<field name="show_std_field2" invisible="1"/>
<field name="show_std_field3" invisible="1"/>
<field name="readonly_std_umc1" invisible="1"/>
<field name="readonly_std_umc2" invisible="1"/>
<field name="readonly_std_umc3" invisible="1"/>
</group>


<group name="std_desc_attrs"
col="4"
colspan="4"
string=""
invisible="std_description == False">
<p><b colpspan="4" size="32">Standard Description Parameters: </b><a target="new" href="https://www.omniasolutions.website/blog/developer-and-it-here-you-will-find-post-regarding-very-technical-aspect-of-programming-and-it-those-thinks-are-daily-used-by-omniasolutions-and-we-hope-you-that-will-help-you-3/post/standard-description-39" title="Standard description parameters info" colspan="4"><i class="fa fa-info-circle"></i></a></p>
<separator colspan="1"/>
<group col="4" colspan="4">
<group name="std_desc_attrs"
colspan="4"
invisible="std_description == False">
<group colspan="4" col="4" string="Standard Description Parameters">
<p><a target="new" href="https://www.omniasolutions.website/blog/developer-and-it-here-you-will-find-post-regarding-very-technical-aspect-of-programming-and-it-those-thinks-are-daily-used-by-omniasolutions-and-we-hope-you-that-will-help-you-3/post/standard-description-39" title="Standard description parameters info" colspan="4"><i class="fa fa-info-circle"></i></a></p>
<group colspan="1">
<field name="std_umc1"
force_save="1"
nolabel="1"
readonly="readonly_std_umc1 or engineering_state in ['released','obsoleted']"
invisible="show_std_field1==False"/>
<field name="std_value1"
nolabel="1"
readonly="std_umc1==False and engineering_state in ['released','obsoleted']"
invisible="show_std_field1==False"/>
<field name="std_umc2"
force_save="1"
readonly="readonly_std_umc2 or engineering_state in ['released','obsoleted']"
invisible="show_std_field2==False"/>
<field name="std_value2"
readonly="std_umc2==False and engineering_state in ['released','obsoleted']"
invisible="show_std_field2==False"/>
<field name="std_umc3"
force_save="1"
readonly="readonly_std_umc3 or engineering_state in ['released','obsoleted']"
invisible="show_std_field3==False"/>
<field name="std_value3"
readonly="std_umc3==False and engineering_state in ['released','obsoleted']"
invisible="show_std_field3==False"/>
</group>
</group>
<field name="source_product" invisible="1"/>
<field name="desc_modify" colspan="6"
readonly="engineering_state in ['released','obsoleted']"
invisible="engineering_revision==0"/>
</group>
</group>
<group colspan="1">
<field name="std_umc2"
force_save="1"
nolabel="1"
readonly="readonly_std_umc2 or engineering_state in ['released','obsoleted']"
invisible="show_std_field2==False"/>
<field name="std_value2"
nolabel="1"
readonly="std_umc2==False and engineering_state in ['released','obsoleted']"
invisible="show_std_field2==False"/>
</group>
<group colspan="1">
<field name="std_umc3"
force_save="1"
nolabel="1"
readonly="readonly_std_umc3 or engineering_state in ['released','obsoleted']"
invisible="show_std_field3==False"/>
<field name="std_value3"
nolabel="1"
readonly="std_umc3==False and engineering_state in ['released','obsoleted']"
invisible="show_std_field3==False"/>
</group>
</group>
</group>
<field name="source_product" invisible="1"/>
<field name="desc_modify" colspan="6"
readonly="engineering_state in ['released','obsoleted']"
invisible="engineering_revision==0"/>
</group>
</xpath>
<xpath expr="//notebook[last()]" position="inside">
<page name="technical_infos" string="Technical Information">
Expand Down

0 comments on commit 89dc3b9

Please sign in to comment.