mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-27 19:32:02 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import sale_loyalty_coupon_wizard
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import _, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class SaleLoyaltyCouponWizard(models.TransientModel):
|
||||
_name = 'sale.loyalty.coupon.wizard'
|
||||
_description = 'Sale Loyalty - Apply Coupon Wizard'
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
</sheet>
|
||||
<footer>
|
||||
<button type="object" name="action_apply" string="Apply" class="btn btn-primary" data-hotkey="q"/>
|
||||
<button special="cancel" string="Discard" class="btn btn-secondary" data-hotkey="z"/>
|
||||
<button special="cancel" string="Discard" class="btn btn-secondary" data-hotkey="x"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class SaleLoyaltyRewardWizard(models.TransientModel):
|
||||
_name = 'sale.loyalty.reward.wizard'
|
||||
_description = 'Sale Loyalty - Reward Selection Wizard'
|
||||
|
|
@ -52,4 +52,18 @@ class SaleLoyaltyRewardWizard(models.TransientModel):
|
|||
raise ValidationError(_('Coupon not found while trying to add the following reward: %s', self.selected_reward_id.description))
|
||||
self.order_id._apply_program_reward(self.selected_reward_id, coupon, product=self.selected_product_id)
|
||||
self.order_id._update_programs_and_rewards()
|
||||
self._unlink_unused_coupon_ids()
|
||||
return True
|
||||
|
||||
def action_cancel(self):
|
||||
self.ensure_one()
|
||||
self._unlink_unused_coupon_ids()
|
||||
|
||||
def _unlink_unused_coupon_ids(self):
|
||||
reward_coupons = self.order_id.order_line.coupon_id
|
||||
self.order_id.coupon_point_ids.filtered(
|
||||
lambda points: (
|
||||
points.coupon_id.program_id.applies_on == 'current' and
|
||||
points.coupon_id not in reward_coupons
|
||||
)
|
||||
).coupon_id.sudo().unlink()
|
||||
|
|
|
|||
|
|
@ -11,30 +11,30 @@
|
|||
<field name="reward_ids" invisible="1"/>
|
||||
<field name="multi_product_reward" invisible="1"/>
|
||||
<field name="reward_product_ids" invisible="1"/>
|
||||
<a attrs="{'invisible': [('reward_ids', '!=', [])]}">
|
||||
<a invisible="reward_ids">
|
||||
No rewards available for this customer!
|
||||
</a>
|
||||
<label for="selected_reward_id" string="Choose your reward:" colspan="2"
|
||||
attrs="{'invisible': [('reward_ids', '=', [])]}"/>
|
||||
invisible="not reward_ids"/>
|
||||
<field name="selected_reward_id" widget="radio" colspan="2" nolabel="1"
|
||||
attrs="{'invisible': [('reward_ids', '=', [])]}"/>
|
||||
invisible="not reward_ids"/>
|
||||
<label for="selected_product_id" string="Choose a product:" colspan="2"
|
||||
attrs="{'invisible': [('multi_product_reward', '=', False)]}"/>
|
||||
invisible="not multi_product_reward"/>
|
||||
<field name="selected_product_id" widget="radio" colspan="2" nolabel="1"
|
||||
attrs="{'invisible': [('multi_product_reward', '=', False)]}"/>
|
||||
invisible="not multi_product_reward"/>
|
||||
</group>
|
||||
</sheet>
|
||||
<footer>
|
||||
<!-- Has rewards -->
|
||||
<button type="object" name="action_apply" string="Apply" class="btn btn-primary"
|
||||
attrs="{'invisible': [('reward_ids', '=', [])]}" data-hotkey="q"/>
|
||||
<button special="cancel" string="Discard" class="btn btn-secondary"
|
||||
attrs="{'invisible': [('reward_ids', '=', [])]}" data-hotkey="z"/>
|
||||
invisible="not reward_ids" data-hotkey="q"/>
|
||||
<button type="object" name="action_cancel" string="Discard" class="btn btn-secondary"
|
||||
invisible="not reward_ids" data-hotkey="x"/>
|
||||
<!-- No rewards -->
|
||||
<button special="cancel" string="Discard" class="btn btn-primary"
|
||||
attrs="{'invisible': [('reward_ids', '!=', [])]}" data-hotkey="z"/>
|
||||
invisible="reward_ids" data-hotkey="x"/>
|
||||
<button type="action" name="%(loyalty.loyalty_program_discount_loyalty_action)d" string="Coupons & Loyalty" class="btn btn-secondary float-end"
|
||||
attrs="{'invisible': [('reward_ids', '!=', [])]}" groups="sales_team.group_sale_manager" data-hotkey="q"/>
|
||||
invisible="reward_ids" groups="sales_team.group_sale_manager" data-hotkey="q"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue