Skip to content

Commit

Permalink
[17.0][MIG] sale_order_line_variant_description: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NICO-SOLUTIONS committed Nov 23, 2024
1 parent 60f2f9e commit 80e56e9
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 24 deletions.
1 change: 1 addition & 0 deletions sale_order_line_variant_description/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Contributors
- Alex Comba <[email protected]>
- Simone Vanin <[email protected]>
- Dhara Solanki <[email protected]>
- Nils Coenen <[email protected]>

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion sale_order_line_variant_description/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Sale order line variant description",
"version": "16.0.1.1.0",
"version": "17.0.1.0.0",
"category": "Sales Management",
"author": "Agile Business Group, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/product-variant",
Expand Down
6 changes: 4 additions & 2 deletions sale_order_line_variant_description/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ class SaleOrderLine(models.Model):

@api.onchange("product_id")
def _onchange_product_id_warning(self):
res = super(SaleOrderLine, self)._onchange_product_id_warning()
res = super()._onchange_product_id_warning()
if self.product_id:
product = self.product_id.with_context(lang=self.order_id.partner_id.lang)
self.name = product.get_product_multiline_description_sale()
if product.variant_description_sale:
self.name = product.variant_description_sale
self.name += f"\n{product.variant_description_sale}"

return res
1 change: 1 addition & 0 deletions sale_order_line_variant_description/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Alex Comba \<<[email protected]>\>
- Simone Vanin \<<[email protected]>\>
- Dhara Solanki \<<[email protected]>\>
- Nils Coenen \<<[email protected]>\>
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<li>Alex Comba &lt;<a class="reference external" href="mailto:alex.comba&#64;agilebg.com">alex.comba&#64;agilebg.com</a>&gt;</li>
<li>Simone Vanin &lt;<a class="reference external" href="mailto:simone.vanin&#64;agilebg.com">simone.vanin&#64;agilebg.com</a>&gt;</li>
<li>Dhara Solanki &lt;<a class="reference external" href="mailto:dhara.solanki&#64;initos.com">dhara.solanki&#64;initos.com</a>&gt;</li>
<li>Nils Coenen &lt;<a class="reference external" href="mailto:nils.coenen&#64;nico-solutions.de">nils.coenen&#64;nico-solutions.de</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@


class TestSaleOrderLineVariantDescription(TransactionCase):
def setUp(self):
super(TestSaleOrderLineVariantDescription, self).setUp()
self.fiscal_position_model = self.env["account.fiscal.position"]
self.tax_model = self.env["account.tax"]
self.pricelist_model = self.env["product.pricelist"]
self.uom_uom_model = self.env["uom.uom"]
self.product_tmpl_model = self.env["product.template"]
self.product_model = self.env["product.product"]
self.so_model = self.env["sale.order"]
self.so_line_model = self.env["sale.order.line"]
self.partner = self.env.ref("base.res_partner_1")
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.fiscal_position_model = cls.env["account.fiscal.position"]
cls.tax_model = cls.env["account.tax"]
cls.pricelist_model = cls.env["product.pricelist"]
cls.uom_uom_model = cls.env["uom.uom"]
cls.product_tmpl_model = cls.env["product.template"]
cls.product_model = cls.env["product.product"]
cls.so_model = cls.env["sale.order"]
cls.so_line_model = cls.env["sale.order.line"]
cls.partner = cls.env.ref("base.res_partner_1")

def test_product_id_change(self):
pricelist = self.pricelist_model.search([("name", "=", "Public Pricelist")])[0]
pricelist = self.pricelist_model.search([("name", "=", "Public Pricelist")])
if not pricelist:
pricelist = self.pricelist_model.create(
{"name": "Public Pricelist", "currency_id": self.env.ref("base.USD").id}
)
pricelist = pricelist[0]

uom = self.uom_uom_model.search([("name", "=", "Units")])[0]
tax_include = self.tax_model.create(
dict(name="Include tax", amount="0.21", price_include=True)
Expand Down Expand Up @@ -55,4 +62,7 @@ def test_product_id_change(self):
}
)
so_line._onchange_product_id_warning()
self.assertEqual(product.variant_description_sale, so_line.name)
so_line_name_without_product_name = so_line.name.split("\n", 1)[-1]
self.assertEqual(
product.variant_description_sale, so_line_name_without_product_name
)
10 changes: 2 additions & 8 deletions sale_order_line_variant_description/views/product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,25 @@
<!-- © 2015-17 Alex Comba - Agile Business Group
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>

<record id="product_normal_form_view" model="ir.ui.view">
<field name="name">product.product.form</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view" />
<field name="arch" type="xml">
<field name="description_sale" position="attributes">
<attribute
name="attrs"
>{'invisible': [('product_variant_count', '&gt;', 1)]}</attribute>
<attribute name="invisible">product_variant_count > 1</attribute>
</field>
<field name="description_sale" position="after">
<field
name="variant_description_sale"
attrs="{'invisible': [('product_variant_count', '=', 1)]}"
colspan="2"
invisible="product_variant_count == 1"
nolabel="1"
placeholder="This note is added to sales orders and invoices."
/>
</field>
</field>
</record>

<record id="product_variant_easy_edit_view" model="ir.ui.view">
<field name="name">product.product.view.form.easy</field>
<field name="model">product.product</field>
Expand All @@ -37,6 +33,4 @@
</xpath>
</field>
</record>


</odoo>

0 comments on commit 80e56e9

Please sign in to comment.