137 lines
6.5 KiB
Diff
137 lines
6.5 KiB
Diff
diff --git a/tryton/modules/purchase/purchase.py b/tryton/modules/purchase/purchase.py
|
|
index faf35cecfa..bb564ff9f4 100644
|
|
--- a/tryton/modules/purchase/purchase.py
|
|
+++ b/tryton/modules/purchase/purchase.py
|
|
@@ -1091,16 +1091,13 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
|
|
'company': Eval('company', None),
|
|
},
|
|
search_context={
|
|
- 'locations': If(Bool(Eval('_parent_purchase', {}).get(
|
|
- 'warehouse')),
|
|
- [Eval('_parent_purchase', {}).get('warehouse', None)],
|
|
- []),
|
|
- 'stock_date_end': Eval('_parent_purchase', {}).get(
|
|
- 'purchase_date'),
|
|
+ 'locations': If(Bool(Eval('warehouse')),
|
|
+ [Eval('warehouse', -1)], []),
|
|
+ 'stock_date_end': Eval('purchase_date', None),
|
|
'stock_skip_warehouse': True,
|
|
- 'currency': Eval('_parent_purchase', {}).get('currency'),
|
|
- 'supplier': Eval('_parent_purchase', {}).get('party'),
|
|
- 'purchase_date': Eval('_parent_purchase', {}).get('purchase_date'),
|
|
+ 'currency': Eval('currency', -1),
|
|
+ 'supplier': Eval('supplier', -1),
|
|
+ 'purchase_date': Eval('purchase_date', None),
|
|
'uom': Eval('unit'),
|
|
'taxes': Eval('taxes', []),
|
|
'quantity': Eval('quantity'),
|
|
@@ -1119,7 +1116,7 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
|
|
('product', '=', Eval('product')),
|
|
],
|
|
[]),
|
|
- ('party', '=', Eval('_parent_purchase', {}).get('party')),
|
|
+ ('party', '=', Eval('supplier', -1)),
|
|
],
|
|
states={
|
|
'invisible': Eval('type') != 'line',
|
|
@@ -1153,8 +1150,7 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
|
|
domain=[('parent', '=', None), ['OR',
|
|
('group', '=', None),
|
|
('group.kind', 'in', ['purchase', 'both'])],
|
|
- ('company', '=',
|
|
- Eval('_parent_purchase', {}).get('company', -1)),
|
|
+ ('company', '=', Eval('company', -1)),
|
|
],
|
|
states={
|
|
'invisible': Eval('type') != 'line',
|
|
@@ -1170,6 +1166,9 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
|
|
move_done = fields.Function(fields.Boolean('Moves Done'), 'get_move_done')
|
|
move_exception = fields.Function(fields.Boolean('Moves Exception'),
|
|
'get_move_exception')
|
|
+ warehouse = fields.Function(fields.Many2One(
|
|
+ 'stock.location', "Warehouse"),
|
|
+ 'on_change_with_warehouse')
|
|
from_location = fields.Function(fields.Many2One('stock.location',
|
|
'From Location'), 'get_from_location')
|
|
to_location = fields.Function(fields.Many2One('stock.location',
|
|
@@ -1437,6 +1436,11 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
|
|
return amount
|
|
return Decimal('0.0')
|
|
|
|
+ @fields.depends('purchase', '_parent_purchase.warehouse')
|
|
+ def on_change_with_warehouse(self, name=None):
|
|
+ if self.purchase and self.purchase.warehouse:
|
|
+ return self.purchase.warehouse.id
|
|
+
|
|
def get_from_location(self, name):
|
|
if (self.quantity or 0) >= 0:
|
|
if self.purchase.party.supplier_location:
|
|
diff --git a/tryton/modules/sale/sale.py b/tryton/modules/sale/sale.py
|
|
index 1b0e36a3b3..d628a9d2be 100644
|
|
--- a/tryton/modules/sale/sale.py
|
|
+++ b/tryton/modules/sale/sale.py
|
|
@@ -1143,13 +1143,13 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView):
|
|
'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'),
|
|
+ 'locations': If(Bool(Eval('warehouse')),
|
|
+ [Eval('warehouse', -1)], []),
|
|
+ 'stock_date_end': Eval('sale_date', None),
|
|
'stock_skip_warehouse': True,
|
|
- 'currency': Eval('_parent_sale', {}).get('currency'),
|
|
- 'customer': Eval('_parent_sale', {}).get('party'),
|
|
- 'sale_date': Eval('_parent_sale', {}).get('sale_date'),
|
|
+ 'currency': Eval('currency', -1),
|
|
+ 'customer': Eval('customer', -1),
|
|
+ 'sale_date': Eval('sale_date', None),
|
|
'uom': Eval('unit'),
|
|
'taxes': Eval('taxes', []),
|
|
'quantity': Eval('quantity'),
|
|
@@ -1186,8 +1186,7 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView):
|
|
domain=[('parent', '=', None), ['OR',
|
|
('group', '=', None),
|
|
('group.kind', 'in', ['sale', 'both'])],
|
|
- ('company', '=',
|
|
- Eval('_parent_sale', {}).get('company', -1)),
|
|
+ ('company', '=', Eval('company', -1)),
|
|
],
|
|
states={
|
|
'invisible': Eval('type') != 'line',
|
|
@@ -1205,7 +1204,7 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView):
|
|
move_exception = fields.Function(fields.Boolean('Moves Exception'),
|
|
'get_move_exception')
|
|
warehouse = fields.Function(fields.Many2One('stock.location',
|
|
- 'Warehouse'), 'get_warehouse')
|
|
+ 'Warehouse'), 'on_change_with_warehouse')
|
|
from_location = fields.Function(fields.Many2One('stock.location',
|
|
'From Location'), 'get_from_location')
|
|
to_location = fields.Function(fields.Many2One('stock.location',
|
|
@@ -1430,6 +1429,11 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView):
|
|
def get_warehouse(self, name):
|
|
return self.sale.warehouse.id if self.sale.warehouse else None
|
|
|
|
+ @fields.depends('sale', '_parent_sale.warehouse')
|
|
+ def on_change_with_warehouse(self, name=None):
|
|
+ if self.sale and self.sale.warehouse:
|
|
+ return self.sale.warehouse.id
|
|
+
|
|
def get_from_location(self, name):
|
|
if (self.quantity or 0) >= 0:
|
|
if self.warehouse:
|
|
diff --git a/tryton/modules/sale_product_customer/sale.py b/tryton/modules/sale_product_customer/sale.py
|
|
index 4f0c4cca41..f77870d05f 100644
|
|
--- a/tryton/modules/sale_product_customer/sale.py
|
|
+++ b/tryton/modules/sale_product_customer/sale.py
|
|
@@ -22,7 +22,7 @@ class Line(metaclass=PoolMeta):
|
|
('product', '=', Eval('product')),
|
|
],
|
|
[]),
|
|
- ('party', '=', Eval('_parent_sale', {}).get('party')),
|
|
+ ('party', '=', Eval('customer', -1)),
|
|
],
|
|
states={
|
|
'invisible': Eval('type') != 'line',
|