Skip to content

Commit

Permalink
[IMP] sale_order_secondary_unit: Fix test
Browse files Browse the repository at this point in the history
[IMP] sale_order_secondary_unit: pre-commit auto fixes

[IMP] sale_order_secondary_unit: Fix unit test

[IMP] sale_order_secondary_unit: Fix Odoo test
  • Loading branch information
mmrondon committed Jul 24, 2024
1 parent 1ce579a commit 7d1dfe7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions sale_order_secondary_unit/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def onchange_sale_secondary_uom_id(self):

@api.model_create_multi
def create(self, vals_list):
templates = super(ProductTemplate, self).create(vals_list)
templates = super().create(vals_list)
# This is needed to set given values to first variant after creation
for template, vals in zip(templates, vals_list):
for template, vals in zip(templates, vals_list, strict=True):
related_vals = {}
if vals.get("sale_secondary_uom_id"):
related_vals["sale_secondary_uom_id"] = vals["sale_secondary_uom_id"]

Check warning on line 69 in sale_order_secondary_unit/models/product_template.py

View check run for this annotation

Codecov / codecov/patch

sale_order_secondary_unit/models/product_template.py#L69

Added line #L69 was not covered by tests
Expand Down
6 changes: 4 additions & 2 deletions sale_order_secondary_unit/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ class SaleOrderLine(models.Model):
"product_uom_qty",
)
def _compute_product_uom_qty(self):
super()._compute_product_uom_qty()
res = super()._compute_product_uom_qty()
for line in self:
line._compute_helper_target_field_qty()
return res

@api.depends("product_id")
def _compute_product_uom(self):
super()._compute_product_uom()
res = super()._compute_product_uom()
for line in self:
line._onchange_helper_product_uom_for_secondary()
return res

@api.onchange("product_id")
def _onchange_product_id_warning(self):
Expand Down
11 changes: 7 additions & 4 deletions sale_order_secondary_unit/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
: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 @@ -274,7 +275,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 @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

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

span.section-subtitle {
Expand Down Expand Up @@ -439,7 +440,9 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">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
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ def setUpClass(cls):
cls.product_uom_kg = cls.env.ref("uom.product_uom_kgm")
cls.product_uom_gram = cls.env.ref("uom.product_uom_gram")
cls.product_uom_unit = cls.env.ref("uom.product_uom_unit")
cls.price_list = cls.env["product.pricelist"].create(
{"name": "price list for test"}
)
cls.product = cls.env["product.product"].create(
{
"name": "test",
Expand Down Expand Up @@ -54,7 +51,6 @@ def setUpClass(cls):
cls.partner = cls.env["res.partner"].create({"name": "test - partner"})
with Form(cls.env["sale.order"]) as order_form:
order_form.partner_id = cls.partner
order_form.pricelist_id = cls.price_list
with order_form.order_line.new() as line_form:
line_form.product_id = cls.product
line_form.product_uom_qty = 1
Expand All @@ -75,7 +71,7 @@ def test_onchange_secondary_unit_product_uom_qty(self):
self.assertEqual(self.order.order_line.secondary_uom_qty, 7.0)

def test_default_secondary_unit(self):
self.order.order_line.product_id_change()
self.order.order_line._onchange_product_id_warning()
self.assertEqual(self.order.order_line.secondary_uom_id, self.secondary_unit)

def test_onchange_order_product_uom(self):
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
odoo_test_helper
odoo-addon-product_secondary_unit @ git+https://github.com/OCA/product-attribute.git@refs/pull/1560/head#subdirectory=product_secondary_unit
odoo-addon-product_secondary_unit @ git+https://github.com/OCA/product-attribute.git@refs/pull/1560/head#subdirectory=product_secondary_unit

0 comments on commit 7d1dfe7

Please sign in to comment.