mirror of
https://github.com/NaN-tic/trytond-stock_external.git
synced 2023-12-14 03:32:57 +01:00
unit_price_required in stock.move is False when shipment is external
#157448
This commit is contained in:
parent
afe6507cdb
commit
184274dc16
2 changed files with 27 additions and 1 deletions
16
shipment.py
16
shipment.py
|
@ -125,6 +125,9 @@ class ShipmentExternal(Workflow, ModelSQL, ModelView):
|
||||||
('to_location', '=', Eval('to_location')),
|
('to_location', '=', Eval('to_location')),
|
||||||
('company', '=', Eval('company')),
|
('company', '=', Eval('company')),
|
||||||
],
|
],
|
||||||
|
context={
|
||||||
|
'stock_external': True,
|
||||||
|
},
|
||||||
depends=['state', 'from_location', 'to_location', 'planned_date',
|
depends=['state', 'from_location', 'to_location', 'planned_date',
|
||||||
'company'])
|
'company'])
|
||||||
state = fields.Selection([
|
state = fields.Selection([
|
||||||
|
@ -402,3 +405,16 @@ class Move(metaclass=PoolMeta):
|
||||||
continue
|
continue
|
||||||
moves_to_check.append(move)
|
moves_to_check.append(move)
|
||||||
super(Move, cls).check_origin(moves_to_check, types)
|
super(Move, cls).check_origin(moves_to_check, types)
|
||||||
|
|
||||||
|
@fields.depends('from_location', 'to_location')
|
||||||
|
def on_change_with_unit_price_required(self, name=None):
|
||||||
|
External = Pool().get('stock.shipment.external')
|
||||||
|
|
||||||
|
unit_price_required = super(Move, self).on_change_with_unit_price_required(name)
|
||||||
|
|
||||||
|
if Transaction().context.get('stock_external', False) or (
|
||||||
|
hasattr(self, 'shipment') and self.shipment
|
||||||
|
and isinstance(self.shipment, External)):
|
||||||
|
return False
|
||||||
|
|
||||||
|
return unit_price_required
|
||||||
|
|
|
@ -19,6 +19,10 @@ class StockExternalTestCase(CompanyTestMixin, ModuleTestCase):
|
||||||
Location = pool.get('stock.location')
|
Location = pool.get('stock.location')
|
||||||
Shipment = pool.get('stock.shipment.external')
|
Shipment = pool.get('stock.shipment.external')
|
||||||
Party = pool.get('party.party')
|
Party = pool.get('party.party')
|
||||||
|
Move = pool.get('stock.move')
|
||||||
|
|
||||||
|
# moves has stock_external context
|
||||||
|
self.assertEqual(Shipment.moves.context.get('stock_external'), True)
|
||||||
|
|
||||||
# Create Company
|
# Create Company
|
||||||
party = Party(name='Party')
|
party = Party(name='Party')
|
||||||
|
@ -31,12 +35,18 @@ class StockExternalTestCase(CompanyTestMixin, ModuleTestCase):
|
||||||
party, = Party.create([{
|
party, = Party.create([{
|
||||||
'name': 'Customer',
|
'name': 'Customer',
|
||||||
}])
|
}])
|
||||||
Shipment.create([{
|
shipment, = Shipment.create([{
|
||||||
'company': company.id,
|
'company': company.id,
|
||||||
'party': party.id,
|
'party': party.id,
|
||||||
'from_location': supplier.id,
|
'from_location': supplier.id,
|
||||||
'to_location': storage.id,
|
'to_location': storage.id,
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
# unit_price_required is false when shipment is external
|
||||||
|
move = Move()
|
||||||
|
move.shipment = shipment
|
||||||
|
self.assertEqual(move.unit_price_required, False)
|
||||||
|
|
||||||
for from_, to in [
|
for from_, to in [
|
||||||
(supplier, supplier),
|
(supplier, supplier),
|
||||||
(supplier, customer),
|
(supplier, customer),
|
||||||
|
|
Loading…
Reference in a new issue