Skip to content

Commit

Permalink
[MIG] product_secondary_unit: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
achulii authored and alexey-pelykh committed Jul 17, 2024
1 parent 7665d45 commit 39fc068
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 14 deletions.
1 change: 0 additions & 1 deletion product_dimension/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down
2 changes: 1 addition & 1 deletion product_secondary_unit/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Product Secondary Unit",
"summary": "Set a secondary unit per product",
"version": "16.0.1.0.2",
"version": "17.0.1.0.0",
"development_status": "Production/Stable",
"category": "Product",
"website": "https://github.com/OCA/product-attribute",
Expand Down
4 changes: 2 additions & 2 deletions product_secondary_unit/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ def _compute_secondary_uom_ids(self):
for variant in self:
variant.secondary_uom_ids = (
variant.product_tmpl_id.secondary_uom_ids.filtered(
lambda s: s.product_id == variant or not s.product_id
lambda s, v=variant: s.product_id == v or not s.product_id
)
)

def _inverse_secondary_uom_ids(self):
for variant in self:
variant.product_tmpl_id.secondary_uom_ids = (
variant.product_tmpl_id.secondary_uom_ids.filtered(
lambda s: s.product_id != variant
lambda s, v=variant: s.product_id != v
)
+ variant.secondary_uom_ids
)
2 changes: 1 addition & 1 deletion product_secondary_unit/models/product_second_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def name_search(self, name="", args=None, operator="ilike", limit=100):
args = []
units = self.search([("code", "=", name)] + args, limit=1)
if not units:
return super(ProductSecondaryUnit, self).name_search(
return super().name_search(
name=name, args=args, operator=operator, limit=limit
)
return units.name_get()
11 changes: 7 additions & 4 deletions product_secondary_unit/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +276,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +302,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -423,7 +424,9 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand Down
2 changes: 1 addition & 1 deletion product_secondary_unit/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SecondaryUnitFake(models.Model):
name = fields.Char()
product_id = fields.Many2one("product.product", "Product", readonly=True)
product_uom_qty = fields.Float(
store=True, readonly=False, compute="_compute_product_uom_qty"
store=True, readonly=False, compute="_compute_product_uom_qty", precompute=True
)
product_uom_id = fields.Many2one("uom.uom", string="Product Unit of Measure")

Expand Down
3 changes: 1 addition & 2 deletions product_secondary_unit/tests/test_secondary_unit_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
cls.loader.restore_registry()
return super(TestProductSecondaryUnitMixin, cls).tearDownClass()
return super().tearDownClass()

def test_product_secondary_unit_mixin(self):
fake_model = self.secondary_unit_fake
Expand All @@ -82,7 +82,6 @@ def test_product_secondary_unit_mixin(self):
fake_model.write(
{"secondary_uom_qty": 1, "secondary_uom_id": self.secondary_unit_box_10.id}
)
fake_model.flush()
fake_model.product_uom_id = self.product_uom_dozen
fake_model._onchange_helper_product_uom_for_secondary()
self.assertEqual(fake_model.secondary_uom_qty, 12)
Expand Down
4 changes: 2 additions & 2 deletions product_secondary_unit/views/product_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
<field name="secondary_uom_ids" colspan="4" nolabel="1">
<tree editable="bottom" decoration-muted="(not active)">
<field name="active" widget="boolean_toggle" />
<field name="product_tmpl_id" invisible="1" />
<field name="product_tmpl_id" column_invisible="1" />
<field
name="product_id"
domain="[('product_tmpl_id', '=', parent.id)]"
groups="product.group_product_variant"
options="{'no_create': True}"
attrs="{'column_invisible': [('parent.product_variant_count', '&lt;=', 1)]}"
column_invisible="parent.product_variant_count &lt;= 1"
/>
<field name="code" />
<field name="name" />
Expand Down

0 comments on commit 39fc068

Please sign in to comment.