[IMP] point_of_sale, pos_discount: move discount data to pos_discount
Prior to this commit, the discount product was created at the installation of the point_of_sale module which does not make sense as this product is only used in the pos_discount module. We change this in this commit to also prevent the discount product to be shown in the frontend of the PoS when the user does not have the pos_discount module installed and abling him to download demo data on the flight if he does not have other products available. closes odoo/odoo#142831 Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
@@ -20,10 +20,6 @@
|
||||
<field name="l10n_in_hsn_code">3921.90.99</field>
|
||||
<field name="l10n_in_hsn_description">Other plates, sheets film , foil and strip, of plastics</field>
|
||||
</record>
|
||||
<record id="point_of_sale.product_product_consumable" model="product.product">
|
||||
<field name="l10n_in_hsn_code">8443.32.90</field>
|
||||
<field name="l10n_in_hsn_description">Other, capable of connecting to an automatic data processing machine or to a network</field>
|
||||
</record>
|
||||
<record id="point_of_sale.monitor_stand" model="product.product">
|
||||
<field name="l10n_in_hsn_code">9403</field>
|
||||
<field name="l10n_in_hsn_description">Other furniture and parts thereof.</field>
|
||||
|
||||
@@ -36,20 +36,6 @@
|
||||
<field name="name">Shop</field>
|
||||
</record>
|
||||
|
||||
<record id="product_product_consumable" model="product.product">
|
||||
<field name="name">Discount</field>
|
||||
<field name="available_in_pos">True</field>
|
||||
<field name="standard_price">0.00</field>
|
||||
<field name="list_price">0.00</field>
|
||||
<field name="weight">0.00</field>
|
||||
<field name="type">consu</field>
|
||||
<field name="categ_id" ref="point_of_sale.product_category_pos"/>
|
||||
<field name="uom_id" ref="uom.product_uom_unit"/>
|
||||
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
||||
<field name="default_code">DISC</field>
|
||||
<field name="purchase_ok">False</field>
|
||||
</record>
|
||||
|
||||
<record id="uom.product_uom_categ_unit" model="uom.category">
|
||||
<field name="is_pos_groupable">True</field>
|
||||
</record>
|
||||
|
||||
@@ -91,9 +91,8 @@ class TestPointOfSaleHttpCommon(AccountTestInvoicingHttpCommon):
|
||||
|
||||
# Archive all existing product to avoid noise during the tours
|
||||
all_pos_product = env['product.product'].search([('available_in_pos', '=', True)])
|
||||
discount = env.ref('point_of_sale.product_product_consumable')
|
||||
cls.tip = env.ref('point_of_sale.product_product_tip')
|
||||
(all_pos_product - discount - cls.tip)._write({'active': False})
|
||||
(all_pos_product - cls.tip)._write({'active': False})
|
||||
|
||||
# In DESKS categ: Desk Pad
|
||||
pos_categ_desks = env.ref('point_of_sale.pos_category_desks')
|
||||
@@ -334,13 +333,8 @@ class TestPointOfSaleHttpCommon(AccountTestInvoicingHttpCommon):
|
||||
'applied_on': '0_product_variant',
|
||||
'min_quantity': 1,
|
||||
'product_id': cls.wall_shelf.id,
|
||||
}), (0, 0, {
|
||||
'compute_price': 'fixed',
|
||||
'fixed_price': 2,
|
||||
'applied_on': '0_product_variant',
|
||||
'min_quantity': 2,
|
||||
'product_id': env.ref('point_of_sale.product_product_consumable').id,
|
||||
})],
|
||||
}),
|
||||
],
|
||||
})
|
||||
|
||||
env['product.pricelist'].create({
|
||||
|
||||
@@ -16,6 +16,7 @@ discount to a customer.
|
||||
""",
|
||||
'depends': ['point_of_sale'],
|
||||
'data': [
|
||||
'data/pos_discount_data.xml',
|
||||
'views/res_config_settings_views.xml',
|
||||
'views/pos_config_views.xml',
|
||||
],
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="product_product_consumable" model="product.product">
|
||||
<field name="name">Discount</field>
|
||||
<field name="available_in_pos">True</field>
|
||||
<field name="standard_price">0.00</field>
|
||||
<field name="list_price">0.00</field>
|
||||
<field name="weight">0.00</field>
|
||||
<field name="type">consu</field>
|
||||
<field name="categ_id" ref="point_of_sale.product_category_pos"/>
|
||||
<field name="uom_id" ref="uom.product_uom_unit"/>
|
||||
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
||||
<field name="default_code">DISC</field>
|
||||
<field name="purchase_ok">False</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -22,7 +22,7 @@ class PosConfig(models.Model):
|
||||
.mapped('config_id')
|
||||
)
|
||||
# Do not modify configs where an opened session exists.
|
||||
product = self.env.ref("point_of_sale.product_product_consumable", raise_if_not_found=False)
|
||||
product = self.env.ref("pos_discount.product_product_consumable", raise_if_not_found=False)
|
||||
for conf in (configs - open_configs):
|
||||
conf.discount_product_id = product if conf.module_pos_discount and product and (not product.company_id or product.company_id == conf.company_id) else False
|
||||
|
||||
@@ -34,5 +34,5 @@ class PosConfig(models.Model):
|
||||
|
||||
def _get_special_products(self):
|
||||
res = super()._get_special_products()
|
||||
default_discount_product = self.env.ref('point_of_sale.product_product_consumable', raise_if_not_found=False) or self.env['product.product']
|
||||
default_discount_product = self.env.ref('pos_discount.product_product_consumable', raise_if_not_found=False) or self.env['product.product']
|
||||
return res | self.env['pos.config'].search([]).mapped('discount_product_id') | default_discount_product
|
||||
|
||||
@@ -13,7 +13,7 @@ class ResConfigSettings(models.TransientModel):
|
||||
|
||||
@api.depends('company_id', 'pos_module_pos_discount', 'pos_config_id')
|
||||
def _compute_pos_discount_product_id(self):
|
||||
default_product = self.env.ref("point_of_sale.product_product_consumable", raise_if_not_found=False) or self.env['product.product']
|
||||
default_product = self.env.ref("pos_discount.product_product_consumable", raise_if_not_found=False) or self.env['product.product']
|
||||
for res_config in self:
|
||||
discount_product = res_config.pos_config_id.discount_product_id or default_product
|
||||
if res_config.pos_module_pos_discount and (not discount_product.company_id or discount_product.company_id == res_config.company_id):
|
||||
|
||||
Reference in New Issue
Block a user