[MOV] (_ => sale_)loyalty_delivery: merge modules

There is no need to have two bridges linking delivery & loyalty.
The two modules held the two parts of the same logic, making no
sense to keep the two modules separate.

Task-3420579

Part-of: odoo/odoo#129572
This commit is contained in:
Victor Feyens
2023-08-03 19:31:14 +02:00
parent b845753f0c
commit 4396f171ef
16 changed files with 37 additions and 131 deletions
@@ -13,7 +13,7 @@
<field name="all_discount_product_ids" invisible="1"/>
<sheet>
<group>
<group string="Reward" id="reward_type_group">
<group string="Reward" name="reward_type_group">
<field name="reward_type" widget="selection" attrs="{'readonly' : [('program_type', '=', 'buy_x_get_y')]}"/>
<label for="discount" attrs="{'invisible': [('reward_type', '!=', 'discount')]}"/>
<div class="d-flex flex-row" attrs="{'invisible': [('reward_type', '!=', 'discount')]}">
@@ -94,12 +94,12 @@
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_global_click_edit mx-0 d-flex flex-row">
<div class="o_loyalty_kanban_card_left mw-75 flex-grow-1" id="reward_info">
<div class="o_loyalty_kanban_card_left mw-75 flex-grow-1" name="reward_info">
<t t-if="record.reward_type.raw_value === 'discount'">
<t t-if="record.discount">
<a><field name="discount"/><field name="discount_mode"/> discount <t t-if="record.discount_max_amount.raw_value > 0">( Max <field name="discount_max_amount"/> )</t></a>
</t>
</t>
<t t-if="record.discount_applicability.raw_value === 'specific'">
<br/>
@@ -115,7 +115,7 @@
</t>
<t t-if="record.discount_product_tag_id.raw_value">
<div class="d-flex"><i class="fa fa-tags fa-fw" title="Product Tags"/> <field name="discount_product_tag_id" class="d-inline"/></div>
</t>
</t>
<t t-if="record.discount_product_domain.raw_value &amp;&amp; record.discount_product_domain.raw_value !== '[]'" groups="base.group_no_one">
<div class="d-flex"><i class="fa fa-search fa-fw" title="Product Domain"/> <field name="discount_product_domain" class="d-inline"/></div>
</t>
@@ -132,7 +132,7 @@
</t>
</t>
<t t-if="record.reward_type.raw_value === 'product'">
<t t-elif="record.reward_type.raw_value === 'product'">
<a>Free product</a>
<br/>
<br/>
@@ -141,7 +141,7 @@
</t>
<t t-if="record.reward_product_tag_id.raw_value">
<div class="d-flex"><i class="fa fa-tags fa-fw" title="Product Tags"/> <field name="reward_product_tag_id" class="d-inline"/></div>
</t>
</t>
</t>
</div>
-4
View File
@@ -1,4 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
-15
View File
@@ -1,15 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Coupons & Loyalty - Delivery',
'summary': "Add a free shipping option to your rewards",
'category': 'Sales',
'version': '1.0',
'depends': ['loyalty', 'delivery'],
'data': [
'views/loyalty_reward_views.xml',
],
'installable': True,
'auto_install': True,
'license': 'LGPL-3',
}
@@ -1,69 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * loyalty_delivery
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server saas~16.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-05-30 05:09+0000\n"
"PO-Revision-Date: 2023-05-30 05:09+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: loyalty_delivery
#. odoo-python
#: code:addons/loyalty_delivery/models/loyalty_reward.py:0
#, python-format
msgid " (Max %s)"
msgstr ""
#. module: loyalty_delivery
#: model_terms:ir.ui.view,arch_db:loyalty_delivery.loyalty_reward_view_kanban_inherit_loyalty_delivery
msgid "( Max"
msgstr ""
#. module: loyalty_delivery
#. odoo-python
#: code:addons/loyalty_delivery/models/loyalty_program.py:0
#, python-format
msgid "Automatic promotion: free shipping on orders higher than $50"
msgstr ""
#. module: loyalty_delivery
#: model:ir.model.fields.selection,name:loyalty_delivery.selection__loyalty_reward__reward_type__shipping
msgid "Free Shipping"
msgstr ""
#. module: loyalty_delivery
#. odoo-python
#: code:addons/loyalty_delivery/models/loyalty_reward.py:0
#: model_terms:ir.ui.view,arch_db:loyalty_delivery.loyalty_reward_view_form_inherit_loyalty_delivery
#: model_terms:ir.ui.view,arch_db:loyalty_delivery.loyalty_reward_view_kanban_inherit_loyalty_delivery
#, python-format
msgid "Free shipping"
msgstr ""
#. module: loyalty_delivery
#: model:ir.model,name:loyalty_delivery.model_loyalty_program
msgid "Loyalty Program"
msgstr ""
#. module: loyalty_delivery
#: model:ir.model,name:loyalty_delivery.model_loyalty_reward
msgid "Loyalty Reward"
msgstr ""
#. module: loyalty_delivery
#: model:ir.model.fields,field_description:loyalty_delivery.field_loyalty_reward__reward_type
msgid "Reward Type"
msgstr ""
#. module: loyalty_delivery
#: model:ir.model,name:loyalty_delivery.model_sale_order
msgid "Sales Order"
msgstr ""
@@ -1,6 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import loyalty_program
from . import loyalty_reward
from . import sale_order
@@ -1,13 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class SaleOrder(models.Model):
_inherit = "sale.order"
def _compute_amount_total_without_delivery(self):
self.ensure_one()
lines = self.order_line.filtered(lambda l: l.coupon_id and l.coupon_id.program_type in ['ewallet', 'gift_card'])
return super()._compute_amount_total_without_delivery() - sum(lines.mapped('price_unit'))
@@ -1,4 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import test_loyalty_delivery
+4 -2
View File
@@ -5,8 +5,10 @@
'summary': 'Adds free shipping mechanism in sales orders',
'description': 'Integrate free shipping in sales orders.',
'category': 'Sales/Sales',
'version': '1.0',
'depends': ['sale_loyalty', 'loyalty_delivery'],
'data': [
'views/loyalty_reward_views.xml',
],
'depends': ['sale_loyalty', 'delivery'],
'auto_install': True,
'license': 'LGPL-3',
}
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import loyalty_program
from . import loyalty_reward
from . import sale_order
from . import sale_order_line
@@ -3,6 +3,7 @@
from odoo import _, api, models
class LoyaltyProgram(models.Model):
_inherit = 'loyalty.program'
@@ -3,6 +3,7 @@
from odoo import _, fields, models
class LoyaltyReward(models.Model):
_inherit = 'loyalty.reward'
@@ -4,9 +4,19 @@
from odoo import _, models
from odoo.fields import Command
class SaleOrder(models.Model):
_inherit = 'sale.order'
# delivery overrides
def _compute_amount_total_without_delivery(self):
self.ensure_one()
lines = self.order_line.filtered(lambda l: l.coupon_id and l.coupon_id.program_type in ['ewallet', 'gift_card'])
return super()._compute_amount_total_without_delivery() - sum(lines.mapped('price_unit'))
# sale_loyalty overrides
def _get_no_effect_on_threshold_lines(self):
self.ensure_one()
lines = self.order_line.filtered(lambda line:\
@@ -2,3 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import test_free_shipping_reward
from . import test_loyalty_delivery
@@ -10,7 +10,7 @@ class TestSaleCouponProgramRules(TestSaleCouponCommon):
@classmethod
def setUpClass(cls):
super(TestSaleCouponProgramRules, cls).setUpClass()
super().setUpClass()
cls.iPadMini = cls.env['product.product'].create({'name': 'Large Cabinet', 'list_price': 320.0})
tax_15pc_excl = cls.env['account.tax'].create({
'name': "15% Tax excl",
@@ -10,7 +10,7 @@ class TestLoyaltyDeliveryCost(common.TransactionCase):
@classmethod
def setUpClass(cls):
super(TestLoyaltyDeliveryCost, cls).setUpClass()
super().setUpClass()
cls.SaleOrder = cls.env['sale.order']
cls.partner_1 = cls.env['res.partner'].create({'name': 'My Test Customer'})
cls.pricelist = cls.env['product.pricelist'].create({
@@ -71,7 +71,6 @@ class TestLoyaltyDeliveryCost(common.TransactionCase):
self.assertEqual(order.order_line.filtered('is_delivery').price_total, 0)
def test_free_delivery_cost_with_ewallet(self):
"""
Automatic free shipping of a delivery carrier should not be affected by the
@@ -154,7 +153,6 @@ class TestLoyaltyDeliveryCost(common.TransactionCase):
self.product_delivery.list_price
)
def _apply_promo_code(self, order, code, no_reward_fail=True):
status = order._try_apply_code(code)
if 'error' in status:
@@ -1,15 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="loyalty_reward_view_form_inherit_loyalty_delivery" model="ir.ui.view">
<field name="name">loyalty.reward.view.form.inherit.loyalty.delivery</field>
<field name="model">loyalty.reward</field>
<field name="inherit_id" ref="loyalty.loyalty_reward_view_form"/>
<field name="arch" type="xml">
<xpath expr="//group[@id='reward_type_group']" position="after">
<group name="reward_type_group" position="after">
<group id="shipping" string="Free shipping" attrs="{'invisible': [('reward_type', '!=', 'shipping')]}">
<field name="discount_max_amount"/>
</group>
</xpath>
</group>
</field>
</record>
@@ -18,13 +19,14 @@
<field name="model">loyalty.reward</field>
<field name="inherit_id" ref="loyalty.loyalty_reward_view_kanban"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='reward_info']" position="inside">
<t t-if="record.reward_type.raw_value === 'shipping'">
<div name="reward_info" position="inside">
<t t-elif="record.reward_type.raw_value === 'shipping'">
<a>Free shipping <t t-if="record.discount_max_amount.raw_value > 0">( Max <field name="discount_max_amount"/> )</t></a>
<br/><br/>
</t>
</xpath>
<br/>
<br/>
</t>
</div>
</field>
</record>
</odoo>