changeset d857a4932508 in modules/purchase:default
details: https://hg.tryton.org/modules/purchase?cmd=changeset;node=d857a4932508
description:
Allow copying attachments and notes to created records
issue9154
review266971002
diffstat:
purchase.py | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diffs (53 lines):
diff -r 41795a80ceb5 -r d857a4932508 purchase.py
--- a/purchase.py Mon Apr 13 12:21:55 2020 +0200
+++ b/purchase.py Mon Apr 13 17:25:02 2020 +0200
@@ -20,6 +20,8 @@
from trytond.transaction import Transaction
from trytond.pool import Pool
+from trytond.ir.attachment import AttachmentCopyMixin
+from trytond.ir.note import NoteCopyMixin
from trytond.modules.account.tax import TaxableMixin
from trytond.modules.account_product.exceptions import AccountError
from trytond.modules.company.model import (
@@ -59,7 +61,9 @@
return classmethod(method)
-class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin):
+class Purchase(
+ Workflow, ModelSQL, ModelView, TaxableMixin,
+ AttachmentCopyMixin, NoteCopyMixin):
'Purchase'
__name__ = 'purchase.purchase'
_rec_name = 'number'
@@ -670,6 +674,13 @@
return attributes
@classmethod
+ def get_resources_to_copy(cls, name):
+ return {
+ 'stock.shipment.in.return',
+ 'account.invoice',
+ }
+
+ @classmethod
def copy(cls, purchases, default=None):
if default is None:
default = {}
@@ -773,6 +784,7 @@
invoice.save()
Invoice.update_taxes([invoice])
+ self.copy_resources_to(invoice)
return invoice
def create_move(self, move_type):
@@ -814,6 +826,7 @@
return_shipment = self._get_return_shipment()
return_shipment.moves = return_moves
return_shipment.save()
+ self.copy_resources_to(return_shipment)
ShipmentInReturn.wait([return_shipment])
return return_shipment