Set company context in product instance
This ensures that the correct value for field depending on the company from product is used. issue8690 review252281002
This commit is contained in:
1 parent
f729a9960e
commit
96df490e97
2 files changed
+11
-5
No files matched your search
+3
-3
@@ -89,8 +89,8 @@ class Product(metaclass=PoolMeta):
|
||||
quantity = Transaction().context.get('quantity') or 0
|
||||
return cls.get_sale_price(products, quantity=quantity)
|
||||
|
||||
@staticmethod
|
||||
def get_sale_price(products, quantity=0):
|
||||
@classmethod
|
||||
def get_sale_price(cls, products, quantity=0):
|
||||
'''
|
||||
Return the sale price for products and quantity.
|
||||
It uses if exists from the context:
|
||||
@@ -119,7 +119,7 @@ class Product(metaclass=PoolMeta):
|
||||
user = User(Transaction().user)
|
||||
|
||||
for product in products:
|
||||
prices[product.id] = product.list_price
|
||||
prices[product.id] = product.list_price_used
|
||||
if uom and product.default_uom.category == uom.category:
|
||||
prices[product.id] = Uom.compute_price(
|
||||
product.default_uom, prices[product.id], uom)
|
||||
|
||||
@@ -1011,6 +1011,8 @@ class SaleLine(sequence_ordered(), ModelSQL, ModelView):
|
||||
'stock_date_end': Eval('_parent_sale', {}).get('sale_date'),
|
||||
'stock_skip_warehouse': True,
|
||||
# From _get_context_sale_price
|
||||
'company': Eval(
|
||||
'_parent_sale', {}).get('company', None),
|
||||
'currency': Eval('_parent_sale', {}).get('currency'),
|
||||
'customer': Eval('_parent_sale', {}).get('party'),
|
||||
'sale_date': Eval('_parent_sale', {}).get('sale_date'),
|
||||
@@ -1136,8 +1138,10 @@ class SaleLine(sequence_ordered(), ModelSQL, ModelView):
|
||||
'''
|
||||
return {}
|
||||
|
||||
@fields.depends('sale', '_parent_sale.currency', '_parent_sale.party',
|
||||
'_parent_sale.sale_date', 'unit', 'product', 'taxes')
|
||||
@fields.depends(
|
||||
'sale', '_parent_sale.currency', '_parent_sale.party',
|
||||
'_parent_sale.sale_date', '_parent_sale.company',
|
||||
'unit', 'product', 'taxes')
|
||||
def _get_context_sale_price(self):
|
||||
context = {}
|
||||
if self.sale:
|
||||
@@ -1146,6 +1150,8 @@ class SaleLine(sequence_ordered(), ModelSQL, ModelView):
|
||||
if self.sale.party:
|
||||
context['customer'] = self.sale.party.id
|
||||
context['sale_date'] = self.sale.sale_date
|
||||
if self.sale.company:
|
||||
context['company'] = self.sale.company.id
|
||||
if self.unit:
|
||||
context['uom'] = self.unit.id
|
||||
elif self.product:
|
||||
|
||||
Reference in new issue
Block a user