Skip to content

Commit

Permalink
sale_loyalty_criteria_order_based: Adapt to 17.0 odoo changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mmequignon committed Oct 25, 2024
1 parent cffdf02 commit ba0087c
Show file tree
Hide file tree
Showing 21 changed files with 351 additions and 362 deletions.
10 changes: 6 additions & 4 deletions sale_loyalty_criteria_order_based/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Sales Coupon based on Sales Order values
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--promotion-lightgray.png?logo=github
:target: https://github.com/OCA/sale-promotion/tree/17.0/sale_coupon_criteria_order_based
:target: https://github.com/OCA/sale-promotion/tree/17.0/sale_loyalty_criteria_order_based
:alt: OCA/sale-promotion
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-promotion-17-0/sale-promotion-17-0-sale_coupon_criteria_order_based
:target: https://translation.odoo-community.org/projects/sale-promotion-17-0/sale-promotion-17-0-sale_loyalty_criteria_order_based
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/sale-promotion&target_branch=17.0
Expand Down Expand Up @@ -55,7 +55,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-promotion/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sale-promotion/issues/new?body=module:%20sale_coupon_criteria_order_based%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/sale-promotion/issues/new?body=module:%20sale_loyalty_criteria_order_based%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -77,6 +77,8 @@ Contributors

- Pilar Vargas

- MmeQuignon <[email protected]>

Maintainers
-----------

Expand All @@ -90,6 +92,6 @@ 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.

This module is part of the `OCA/sale-promotion <https://github.com/OCA/sale-promotion/tree/17.0/sale_coupon_criteria_order_based>`_ project on GitHub.
This module is part of the `OCA/sale-promotion <https://github.com/OCA/sale-promotion/tree/17.0/sale_loyalty_criteria_order_based>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
7 changes: 5 additions & 2 deletions sale_loyalty_criteria_order_based/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"license": "AGPL-3",
"category": "Sale",
"website": "https://github.com/OCA/sale-promotion",
"depends": ["sale_coupon"],
"data": ["views/coupon_program_view.xml"],
"depends": ["sale_loyalty"],
"data": [
"views/loyalty_program.xml",
"views/loyalty_rule.xml",
],
}
58 changes: 0 additions & 58 deletions sale_loyalty_criteria_order_based/i18n/es.po

This file was deleted.

69 changes: 0 additions & 69 deletions sale_loyalty_criteria_order_based/i18n/it.po

This file was deleted.

This file was deleted.

6 changes: 3 additions & 3 deletions sale_loyalty_criteria_order_based/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from . import coupon_rule
from . import coupon_program
from . import coupon_coupon
from . import sale_order
from . import loyalty_rule
from . import loyalty_program
15 changes: 0 additions & 15 deletions sale_loyalty_criteria_order_based/models/coupon_coupon.py

This file was deleted.

59 changes: 0 additions & 59 deletions sale_loyalty_criteria_order_based/models/coupon_program.py

This file was deleted.

13 changes: 0 additions & 13 deletions sale_loyalty_criteria_order_based/models/coupon_rule.py

This file was deleted.

34 changes: 34 additions & 0 deletions sale_loyalty_criteria_order_based/models/loyalty_program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2022 Ooops404
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import ast

from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo.osv.expression import expression


class LoyaltyProgram(models.Model):
_inherit = "loyalty.program"

rule_order_domain = fields.Char(string="Based on Order", default="[]")

@api.constrains("rule_order_domain")
def _constrain_rule_order_domain(self):
model = self.env["sale.order"]
for program in self:
try:
domain = ast.literal_eval(program.rule_order_domain)
# Ensuring that domain is valid for sale.order
expression(domain, model)
except Exception as e:
raise UserError(_("Invalid domain on program")) from e

def _is_valid_order(self, order):
"""Check that we can apply the program on current order"""
self.ensure_one()
order.ensure_one()
domain = ast.literal_eval(self.rule_order_domain)
if domain:
return bool(order.filtered_domain(domain))
return True
Loading

0 comments on commit ba0087c

Please sign in to comment.