mirror of
https://github.com/NaN-tic/trytond-stock_origin_sale.git
synced 2023-12-14 03:23:05 +01:00
Changed the way the sale of a ShipmentOut is computed: The sale of the first stock move with a sale line found
This commit is contained in:
parent
b3c2adada6
commit
955357b153
0
MANIFEST.in
Executable file → Normal file
0
MANIFEST.in
Executable file → Normal file
1
__init__.py
Executable file → Normal file
1
__init__.py
Executable file → Normal file
|
@ -8,6 +8,5 @@ from .sale import *
|
|||
|
||||
def register():
|
||||
Pool.register(
|
||||
Sale,
|
||||
ShipmentOut,
|
||||
module='stock_origin_sale', type_='model')
|
||||
|
|
0
doc/index.rst
Executable file → Normal file
0
doc/index.rst
Executable file → Normal file
29
sale.py
29
sale.py
|
@ -1,29 +0,0 @@
|
|||
#This file is part stock_origin_purchase module for Tryton.
|
||||
#The COPYRIGHT file at the top level of this repository contains
|
||||
#the full copyright notices and license terms.
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
|
||||
__all__ = ['Sale']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
class Sale:
|
||||
__name__ = 'sale.sale'
|
||||
|
||||
def create_shipment(self, shipment_type):
|
||||
shipments = super(Sale, self).create_shipment(shipment_type)
|
||||
if shipment_type == 'out':
|
||||
Shipment = Pool().get('stock.shipment.out')
|
||||
elif shipment_type == 'return':
|
||||
Shipment = Pool().get('stock.shipment.out.return')
|
||||
else:
|
||||
return None
|
||||
|
||||
if shipments:
|
||||
for shipment in shipments:
|
||||
values = {
|
||||
'origin': 'sale.sale,%s' % (self.id),
|
||||
}
|
||||
Shipment.write([shipment], values)
|
||||
return shipments
|
||||
|
14
shipment.py
Executable file → Normal file
14
shipment.py
Executable file → Normal file
|
@ -1,7 +1,8 @@
|
|||
#This file is part stock_origin_sale module for Tryton.
|
||||
#The COPYRIGHT file at the top level of this repository contains
|
||||
#the full copyright notices and license terms.
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.model import fields
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
|
||||
__all__ = ['ShipmentOut']
|
||||
__metaclass__ = PoolMeta
|
||||
|
@ -10,6 +11,17 @@ __metaclass__ = PoolMeta
|
|||
class ShipmentOut:
|
||||
__name__ = 'stock.shipment.out'
|
||||
|
||||
@classmethod
|
||||
def get_origin_value(cls, shipments, name):
|
||||
SaleLine = Pool().get('sale.line')
|
||||
origin = super(ShipmentOut, cls).get_origin_value(shipments, name)
|
||||
for shipment in shipments:
|
||||
for m in shipment.outgoing_moves:
|
||||
if m.origin and isinstance(m.origin, SaleLine):
|
||||
origin[shipment.id] = 'sale.sale,%s' % (m.origin.sale.id)
|
||||
break
|
||||
return origin
|
||||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
return super(ShipmentOut, cls)._get_origin() + ['sale.sale']
|
||||
|
|
0
tests/__init__.py
Executable file → Normal file
0
tests/__init__.py
Executable file → Normal file
0
tests/test_stock_origin_sale.py
Executable file → Normal file
0
tests/test_stock_origin_sale.py
Executable file → Normal file
Loading…
Reference in a new issue