[MERGE] forward port branch saas-11.2 up to e1a2b299b23
This commit is contained in:
@@ -80,6 +80,11 @@ class SaleCouponProgram(models.Model):
|
||||
if self.promo_code_usage == 'no_code_needed':
|
||||
self.promo_code = False
|
||||
|
||||
@api.onchange('reward_product_id')
|
||||
def _onchange_reward_product_id(self):
|
||||
if self.reward_product_id:
|
||||
self.reward_product_uom_id = self.reward_product_id.uom_id
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
program = super(SaleCouponProgram, self).create(vals)
|
||||
|
||||
@@ -39,14 +39,12 @@ class SaleOrder(models.Model):
|
||||
@api.multi
|
||||
@api.returns('self', lambda value: value.id)
|
||||
def copy(self, default=None):
|
||||
order = super(SaleOrder, self).copy(dict(default or {}, order_line=False))
|
||||
for line in self._get_reward_lines():
|
||||
line.copy({'order_id': order.id})
|
||||
order = super(SaleOrder, self).copy(default)
|
||||
order._get_reward_lines().unlink()
|
||||
order.with_context(sale_coupon_no_loop=False)._create_new_no_code_promo_reward_lines()
|
||||
return order
|
||||
|
||||
def action_confirm(self):
|
||||
self.recompute_coupon_lines()
|
||||
self.generated_coupon_ids.write({'state': 'new'})
|
||||
return super(SaleOrder, self).action_confirm()
|
||||
|
||||
|
||||
+19
-9
@@ -25,17 +25,34 @@ class TestSaleCouponCommon(common.TransactionCase):
|
||||
|
||||
self.uom_unit = self.env.ref('uom.product_uom_unit')
|
||||
|
||||
# Taxes
|
||||
self.tax_15pc_excl = self.env['account.tax'].create({
|
||||
'name': "Tax 15%",
|
||||
'amount_type': 'percent',
|
||||
'amount': 15,
|
||||
'type_tax_use': 'sale',
|
||||
})
|
||||
|
||||
self.tax_10pc_incl = self.env['account.tax'].create({
|
||||
'name': "10% Tax incl",
|
||||
'amount_type': 'percent',
|
||||
'amount': 10,
|
||||
'price_include': True,
|
||||
})
|
||||
|
||||
#products
|
||||
self.product_A = self.env['product.product'].create({
|
||||
'name': 'Product A',
|
||||
'list_price': 100,
|
||||
'sale_ok': True
|
||||
'sale_ok': True,
|
||||
'taxes_id': [(6, 0, [self.tax_15pc_excl.id])],
|
||||
})
|
||||
|
||||
self.product_B = self.env['product.product'].create({
|
||||
'name': 'Product B',
|
||||
'list_price': 5,
|
||||
'sale_ok': True
|
||||
'sale_ok': True,
|
||||
'taxes_id': [(6, 0, [self.tax_15pc_excl.id])],
|
||||
})
|
||||
|
||||
# Immediate Program By A + B: get B free
|
||||
@@ -57,10 +74,3 @@ class TestSaleCouponCommon(common.TransactionCase):
|
||||
'rule_products_domain': "[('id', 'in', [%s])]" % (self.product_A.id),
|
||||
'active': True,
|
||||
})
|
||||
|
||||
self.tax_10pc_incl = self.env['account.tax'].create({
|
||||
'name': "10% Tax incl",
|
||||
'amount_type': 'percent',
|
||||
'amount': 10,
|
||||
'price_include': True,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user