Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] product_pricelist_alternative: Migration to 18.0 #1863

Open
wants to merge 9 commits into
base: 18.0
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Project-Id-Version: Odoo Server 18.0+e\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
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 @@
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 @@ -90,8 +90,8 @@
lambda item: item.compute_price == "formula"
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']"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: groups="product.group_sale_pricelist" is removed in 18.0.
Only a single <list> remain whereas before two elements existed

expr="//page[@name='pricelist_rules']/field[@name='item_ids']/list/field[@name='product_tmpl_id']"
position="after"
>
<field name="alternative_pricelist_policy" />
Expand Down
Loading