155 lines
6.8 KiB
Diff
155 lines
6.8 KiB
Diff
diff --git a/tryton/modules/sale/sale.py b/tryton/trytond/trytond/modules/sale/sale.py
|
|
index 3d66f74..b1096c2 100644
|
|
--- a/tryton/modules/sale/sale.py
|
|
+++ b/tryton/modules/sale/sale.py
|
|
@@ -1009,20 +1009,21 @@ class SaleLine(sequence_ordered(), ModelSQL, ModelView):
|
|
'readonly': Eval('sale_state') != 'draft',
|
|
},
|
|
context={
|
|
+ 'company': Eval('company', None),
|
|
+ },
|
|
+ search_context={
|
|
'locations': If(Bool(Eval('_parent_sale', {}).get('warehouse')),
|
|
[Eval('_parent_sale', {}).get('warehouse', 0)], []),
|
|
'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'),
|
|
'uom': Eval('unit'),
|
|
'taxes': Eval('taxes', []),
|
|
'quantity': Eval('quantity'),
|
|
- }, depends=['type', 'sale_state'])
|
|
+ },
|
|
+ depends=['type', 'sale_state', 'company'])
|
|
product_uom_category = fields.Function(
|
|
fields.Many2One('product.uom.category', 'Product Uom Category'),
|
|
'on_change_with_product_uom_category')
|
|
@@ -1080,6 +1081,9 @@ class SaleLine(sequence_ordered(), ModelSQL, ModelView):
|
|
'on_change_with_shipping_date')
|
|
sale_state = fields.Function(fields.Selection(STATES, 'Sale State'),
|
|
'on_change_with_sale_state')
|
|
+ company = fields.Function(
|
|
+ fields.Many2One('company.company', "Company"),
|
|
+ 'on_change_with_company')
|
|
|
|
@classmethod
|
|
def __register__(cls, module_name):
|
|
@@ -1143,7 +1147,7 @@ class SaleLine(sequence_ordered(), ModelSQL, ModelView):
|
|
|
|
@fields.depends(
|
|
'sale', '_parent_sale.currency', '_parent_sale.party',
|
|
- '_parent_sale.sale_date', '_parent_sale.company',
|
|
+ '_parent_sale.sale_date', 'company',
|
|
'unit', 'product', 'taxes')
|
|
def _get_context_sale_price(self):
|
|
context = {}
|
|
@@ -1153,8 +1157,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.company:
|
|
+ context['company'] = self.company.id
|
|
if self.unit:
|
|
context['uom'] = self.unit.id
|
|
elif self.product:
|
|
@@ -1308,6 +1312,11 @@ class SaleLine(sequence_ordered(), ModelSQL, ModelView):
|
|
if self.sale:
|
|
return self.sale.state
|
|
|
|
+ @fields.depends('sale', '_parent_sale.company')
|
|
+ def on_change_with_company(self, name=None):
|
|
+ if self.sale and self.sale.company:
|
|
+ return self.sale.company.id
|
|
+
|
|
def get_invoice_line(self):
|
|
'Return a list of invoice lines for sale line'
|
|
pool = Pool()
|
|
diff --git a/tryton/modules/purchase/purchase.py b/tryton/trytond/trytond/modules/purchase/purchase.py
|
|
index 30ae987..a0459a5 100644
|
|
--- a/tryton/modules/purchase/purchase.py
|
|
+++ b/tryton/modules/purchase/purchase.py
|
|
@@ -967,6 +967,9 @@ class PurchaseLine(sequence_ordered(), ModelSQL, ModelView):
|
|
'required': Bool(Eval('product_supplier')),
|
|
},
|
|
context={
|
|
+ 'company': Eval('company', None),
|
|
+ },
|
|
+ search_context={
|
|
'locations': If(Bool(Eval('_parent_purchase', {}).get(
|
|
'warehouse')),
|
|
[Eval('_parent_purchase', {}).get('warehouse', None)],
|
|
@@ -974,16 +977,13 @@ class PurchaseLine(sequence_ordered(), ModelSQL, ModelView):
|
|
'stock_date_end': Eval('_parent_purchase', {}).get(
|
|
'purchase_date'),
|
|
'stock_skip_warehouse': True,
|
|
- # From _get_context_purchase_price
|
|
- 'company': Eval(
|
|
- '_parent_purchase', {}).get('company', None),
|
|
'currency': Eval('_parent_purchase', {}).get('currency'),
|
|
'supplier': Eval('_parent_purchase', {}).get('party'),
|
|
'purchase_date': Eval('_parent_purchase', {}).get('purchase_date'),
|
|
'uom': Eval('unit'),
|
|
'taxes': Eval('taxes', []),
|
|
'quantity': Eval('quantity'),
|
|
- }, depends=['type', 'purchase_state', 'product_supplier'])
|
|
+ }, depends=['type', 'purchase_state', 'product_supplier', 'company'])
|
|
product_supplier = fields.Many2One(
|
|
'purchase.product_supplier', "Supplier's Product",
|
|
ondelete='RESTRICT',
|
|
@@ -1081,6 +1081,12 @@ class PurchaseLine(sequence_ordered(), ModelSQL, ModelView):
|
|
purchase_state = fields.Function(
|
|
fields.Selection(STATES, 'Purchase State'),
|
|
'on_change_with_purchase_state')
|
|
+ company = fields.Function(
|
|
+ fields.Many2One('company.company', "Company"),
|
|
+ 'on_change_with_company')
|
|
+ currency = fields.Function(
|
|
+ fields.Many2One('currency.currency', 'Currency'),
|
|
+ 'on_change_with_currency')
|
|
|
|
@classmethod
|
|
def __register__(cls, module_name):
|
|
@@ -1144,7 +1150,7 @@ class PurchaseLine(sequence_ordered(), ModelSQL, ModelView):
|
|
|
|
@fields.depends(
|
|
'purchase', '_parent_purchase.currency', '_parent_purchase.party',
|
|
- '_parent_purchase.purchase_date', '_parent_purchase.company',
|
|
+ '_parent_purchase.purchase_date', 'company',
|
|
'unit', 'product', 'product_supplier', 'taxes')
|
|
def _get_context_purchase_price(self):
|
|
context = {}
|
|
@@ -1154,8 +1160,8 @@ class PurchaseLine(sequence_ordered(), ModelSQL, ModelView):
|
|
if self.purchase.party:
|
|
context['supplier'] = self.purchase.party.id
|
|
context['purchase_date'] = self.purchase.purchase_date
|
|
- if self.purchase.company:
|
|
- context['company'] = self.purchase.company.id
|
|
+ if self.company:
|
|
+ context['company'] = self.company.id
|
|
if self.unit:
|
|
context['uom'] = self.unit.id
|
|
elif self.product:
|
|
@@ -1359,6 +1365,16 @@ class PurchaseLine(sequence_ordered(), ModelSQL, ModelView):
|
|
if self.purchase:
|
|
return self.purchase.state
|
|
|
|
+ @fields.depends('purchase', '_parent_purchase.company')
|
|
+ def on_change_with_company(self, name=None):
|
|
+ if self.purchase and self.purchase.company:
|
|
+ return self.purchase.company.id
|
|
+
|
|
+ @fields.depends('purchase', '_parent_purchase.currency')
|
|
+ def on_change_with_currency(self, name=None):
|
|
+ if self.purchase and self.purchase.currency:
|
|
+ return self.purchase.currency.id
|
|
+
|
|
def get_invoice_line(self):
|
|
'Return a list of invoice line for purchase line'
|
|
pool = Pool()
|