Skip to content

Commit

Permalink
[MIG] product_pricelist_alternative: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vvrossem committed Jan 28, 2025
1 parent 5dbaea0 commit 14cc0b5
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion product_pricelist_alternative/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Product Pricelist Alternative",
"version": "16.0.1.2.0",
"version": "18.0.1.0.0",
"development_status": "Beta",
"category": "Product",
"summary": "Calculate product price based on alternative pricelists",
Expand Down
8 changes: 4 additions & 4 deletions product_pricelist_alternative/models/product_pricelist.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2024 Camptocamp (<https://www.camptocamp.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import ValidationError


Expand Down Expand Up @@ -45,9 +45,9 @@ def action_view_is_alternative_to_pricelist(self):
self.ensure_one()
action = {
"type": "ir.actions.act_window",
"name": _("Is Alternative to Pricelist"),
"name": self.env._("Is Alternative to Pricelist"),
"res_model": "product.pricelist",
"view_mode": "tree,form",
"view_mode": "list,form",
"domain": [("id", "in", self.is_alternative_to_pricelist_ids.ids)],
"context": dict(self.env.context, create=False),
}
Expand Down Expand Up @@ -91,7 +91,7 @@ def _check_pricelist_alternative_items_based_on_other_pricelist(self):
and item.base == "pricelist"
):
raise ValidationError(

Check warning on line 93 in product_pricelist_alternative/models/product_pricelist.py

View check run for this annotation

Codecov / codecov/patch

product_pricelist_alternative/models/product_pricelist.py#L93

Added line #L93 was not covered by tests
_(
self.env._(
"Formulas based on another pricelist are not allowed "
"on alternative pricelists."
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2024 Camptocamp (<https://www.camptocamp.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import ValidationError


Expand All @@ -27,7 +27,7 @@ def _check_pricelist_alternative_items_based_on_other_pricelist(self):
and item.pricelist_id.is_alternative_to_pricelist_count
):
raise ValidationError(
_(
self.env._(
"It is not possible to encode this price rule. "
"Formulas based on another pricelist "
"are not allowed on alternative pricelists. "
Expand Down
7 changes: 3 additions & 4 deletions product_pricelist_alternative/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo.fields import Command
from odoo.tests import common, tagged
from odoo.tests import tagged

from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
from odoo.addons.base.tests.common import BaseCommon


@tagged("post_install", "-at_install")
class CommonProductPricelistAlternative(common.TransactionCase):
class CommonProductPricelistAlternative(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env["base"].with_context(**DISABLED_MAIL_CONTEXT).env
cls.datacard = cls.env["product.product"].create(
{"name": "Data card", "list_price": 100}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Copyright 2024 Camptocamp (<https://www.camptocamp.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.exceptions import ValidationError
from odoo.tests import common, tagged
from odoo.tests import tagged

from .common import CommonProductPricelistAlternative


@tagged("post_install", "-at_install")
class TestPricelistAlternative(
CommonProductPricelistAlternative, common.TransactionCase
):
class TestPricelistAlternative(CommonProductPricelistAlternative):
def test_is_alternative_to_pricelist_count(self):
"""Test that the is_alternative_to_pricelist_count is correctly computed"""

Expand All @@ -22,7 +20,7 @@ def test_is_alternative_to_pricelist_count(self):

def test_action_view_is_alternative_to_pricelist(self):
action = self.alternative_pricelist_01.action_view_is_alternative_to_pricelist()
self.assertEqual(action["view_mode"], "tree,form")
self.assertEqual(action["view_mode"], "list,form")
self.assertEqual(
action["domain"][0][2],
self.alternative_pricelist_01.is_alternative_to_pricelist_ids.ids,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</record>

<record id="product_pricelist_item_view_tree" model="ir.ui.view">
<field name="name">product.pricelist.item.tree</field>
<field name="name">product.pricelist.item.list</field>
<field name="model">product.pricelist.item</field>
<field name="inherit_id" ref="product.product_pricelist_item_tree_view" />
<field name="arch" type="xml">
Expand All @@ -23,7 +23,7 @@
</record>

<record id="product_pricelist_item_tree_view_from_product" model="ir.ui.view">
<field name="name">product.pricelist.item.tree</field>
<field name="name">product.pricelist.item.list</field>
<field name="model">product.pricelist.item</field>
<field
name="inherit_id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@
</group>
</group>
<xpath
expr="//page[@name='pricelist_rules']/field[@name='item_ids']/tree/field[@name='product_id']"
position="after"
>
<field name="alternative_pricelist_policy" />
</xpath>
<xpath
expr="//page[@name='pricelist_rules']/field[@name='item_ids']/tree[@groups='product.group_sale_pricelist']/field[@name='name']"
expr="//page[@name='pricelist_rules']/field[@name='item_ids']/list/field[@name='product_tmpl_id']"
position="after"
>
<field name="alternative_pricelist_policy" />
Expand Down

0 comments on commit 14cc0b5

Please sign in to comment.