-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sale_loyalty_criteria_order_based: Adapt to 17.0 odoo changes
- Loading branch information
1 parent
cffdf02
commit ba0087c
Showing
21 changed files
with
351 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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. | ||
|
||
|
@@ -77,6 +77,8 @@ Contributors | |
|
||
- Pilar Vargas | ||
|
||
- MmeQuignon <[email protected]> | ||
|
||
Maintainers | ||
----------- | ||
|
||
|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
53 changes: 0 additions & 53 deletions
53
sale_loyalty_criteria_order_based/i18n/sale_coupon_criteria_order_based.pot
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
59 changes: 0 additions & 59 deletions
59
sale_loyalty_criteria_order_based/models/coupon_program.py
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
sale_loyalty_criteria_order_based/models/loyalty_program.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.