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

[15.0][FIX] sale_coupon_delivery_auto_refresh: validate coupons #140

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sale_coupon_delivery_auto_refresh/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Contributors
* `Tecnativa <https://www.tecnativa.com>`_

* Pilar Vargas
* David Vidal

Maintainers
~~~~~~~~~~~
Expand Down
24 changes: 7 additions & 17 deletions sale_coupon_delivery_auto_refresh/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,12 @@ class SaleOrder(models.Model):
_inherit = "sale.order"

def _auto_refresh_delivery(self):
"""
Override to change context value to refresh coupons after creation
delivery line
"""
self = self.with_context(
skip_auto_refresh_coupons=False, auto_refresh_delivery=True
)
"""When refreshing delivery lines skip coupons auto compute"""
self = self.with_context(skip_auto_refresh_coupons=True)
return super(SaleOrder, self)._auto_refresh_delivery()

def _create_delivery_line(self, carrier, price_unit):
"""
Override to refresh coupons after creation delivery line
"""
if self._check_skip_refresh():
return super()._create_delivery_line(carrier, price_unit)
self_ctx = self.with_context(skip_auto_refresh_coupons=True)
sol = super(SaleOrder, self_ctx)._create_delivery_line(carrier, price_unit)
self._auto_refresh_coupons()
return sol
def recompute_coupon_lines(self):
"""When refreshing promotions skip delivery lines auto compute"""
return super(
SaleOrder, self.with_context(auto_refresh_delivery=True)
).recompute_coupon_lines()
1 change: 1 addition & 0 deletions sale_coupon_delivery_auto_refresh/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
* `Tecnativa <https://www.tecnativa.com>`_

* Pilar Vargas
* David Vidal
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Auto Refresh Coupons with Delivery line</title>
<style type="text/css">

Expand Down Expand Up @@ -433,6 +433,7 @@ <h1>Contributors</h1>
<li>Cetmix &lt;<a class="reference external" href="https://cetmix.com/">https://cetmix.com/</a>&gt;</li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a><ul>
<li>Pilar Vargas</li>
<li>David Vidal</li>
</ul>
</li>
</ul>
Expand Down