[FIX] loyalty: default product for reward in multi company
Steps to reproduce:
-------------------
- being in a multi-company environment;
- have one product made that is first in alphabetical
order of "Internal Reference" throughout the database (e.g. [AAA]);
- make this product specific to one of the companies
(set the "Company" field on the product template)
- go into a different company within the database
(not the one set on this product);
- create a new discount & loyalty record, and set
the "Program Type" to "Discount Code".
Issue:
------
An access rights error occurs.
Cause:
------
When creating a `promo_code` program, we use the first product
that can be sold in the default reward values.
Solution:
---------
Take into account the company in the domain that retrieves
the default product.
opw-3538516
closes odoo/odoo#139008
X-original-commit: d80c28c78bf3237e2526a6370f9c6c0b0f8dc232
Signed-off-by: Thomas Lefebvre (thle) <thle@odoo.com>
This commit is contained in:
@@ -216,7 +216,7 @@ class LoyaltyProgram(models.Model):
|
||||
def _program_type_default_values(self):
|
||||
# All values to change when program_type changes
|
||||
# NOTE: any field used in `rule_ids`, `reward_ids` and `communication_plan_ids` MUST be present in the kanban view for it to work properly.
|
||||
first_sale_product = self.env['product.product'].search([('sale_ok', '=', True)], limit=1)
|
||||
first_sale_product = self.env['product.product'].search([('company_id', 'in', [False, self.env.company.id]), ('sale_ok', '=', True)], limit=1)
|
||||
return {
|
||||
'coupons': {
|
||||
'applies_on': 'current',
|
||||
|
||||
Reference in New Issue
Block a user