Skip to content

Commit

Permalink
[FIX] product_packaging_level: cannot input name with user_defined po…
Browse files Browse the repository at this point in the history
…licy
  • Loading branch information
trisdoan committed Jan 8, 2025
1 parent 7e58978 commit 0239c61
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions product_packaging_level/models/product_packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,10 @@ def _compute_name(self):
# Keep this method to respect translations on level name
@api.depends("product_id", "packaging_level_id", "name_policy")
def _compute_display_name(self):
super()._compute_display_name()
for record in self:
if record.product_id and record.packaging_level_id:
record.display_name = record._get_name_from_policy(lang=self.env.lang)
else:
return super()._compute_display_name()

def _get_name_from_policy(self, lang=None):
new_name = self.name
Expand Down
3 changes: 3 additions & 0 deletions product_packaging_level/models/product_packaging_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class ProductPackagingLevel(models.Model):
_description = "Level management for product.packaging"
_order = "sequence, code"

def _active_languages(self):
return self.env["res.lang"].search([]).ids

Check warning on line 13 in product_packaging_level/models/product_packaging_level.py

View check run for this annotation

Codecov / codecov/patch

product_packaging_level/models/product_packaging_level.py#L13

Added line #L13 was not covered by tests

def _default_language(self):
lang_code = self.env["ir.default"]._get("res.partner", "lang")
def_lang_id = self.env["res.lang"]._get_data(code=lang_code).id
Expand Down
6 changes: 0 additions & 6 deletions product_packaging_level/views/product_packaging_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
<field name="model">product.packaging</field>
<field name="inherit_id" ref="stock.product_packaging_form_view" />
<field name="arch" type="xml">
<field name="name" position="before">
<field name="display_name" string="Packaging" />
</field>
<field name="name" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<xpath expr="//field[@name='package_type_id']" position="after">
<field name="qty_per_level" />
<field name="packaging_level_id" />
Expand Down

0 comments on commit 0239c61

Please sign in to comment.