Add supplier on shipment in returns

issue4035
review22831002
This commit is contained in:
Sergi Almacellas Abellana committed 2016-03-17 15:31:11 +01:00
1 parent 1d5859ffa3
commit b49bf8c7ac
2 files changed
+31

No files matched your search

+2
View File
@@ -730,6 +730,8 @@ class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin):
company=self.company,
from_location=self.warehouse.storage_location,
to_location=self.party.supplier_location,
supplier=self.party,
delivery_address=self.party.address_get(type='delivery'),
)
def create_return_shipment(self, return_moves):
+29
View File
@@ -99,6 +99,35 @@ class ShipmentInReturn:
'by a purchase.'),
})
@classmethod
def __register__(cls, module_name):
pool = Pool()
Move = pool.get('stock.move')
PurchaseLine = pool.get('purchase.line')
Purchase = pool.get('purchase.purchase')
cursor = Transaction().connection.cursor()
sql_table = cls.__table__()
move = Move.__table__()
line = PurchaseLine.__table__()
purchase = Purchase.__table__()
# Migration from 3.8: New supplier field
cursor.execute(*sql_table.select(sql_table.supplier,
where=sql_table.supplier == Null, limit=1))
if cursor.fetchone():
value = sql_table.join(move, condition=(
Concat(cls.__name__ + ',', sql_table.id) == move.shipment)
).join(line, condition=(
Concat(PurchaseLine.__name__ + ',', line.id)
== move.origin)
).join(purchase,
condition=(purchase.id == line.purchase)
).select(purchase.party)
cursor.execute(*sql_table.update(
columns=[sql_table.supplier],
values=[value]))
super(ShipmentInReturn, cls).__register__(module_name)
@classmethod
def write(cls, *args):
pool = Pool()