Update purchase_order.py

This commit is contained in:
zainab2097 2024-09-25 11:41:40 +03:00 committed by GitHub
parent bfe96d83f8
commit bec9911152
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 14 deletions

View File

@ -8,19 +8,6 @@ from dateutil.relativedelta import relativedelta
class PurchaseOrderCustom(models.Model):
_inherit = "purchase.order"
def _prepare_invoice(self):
"""Override to include res_id and res_model in the invoice creation values."""
# Call the original method using super to get the base invoice values
invoice_vals = super(PurchaseOrder, self)._prepare_invoice()
# Add the res_id and res_model to the invoice values
invoice_vals.update({
'res_id': self.id, # Reference to the current purchase order
'res_model': 'purchase.order', # The model of the reference
})
return invoice_vals
def copy(self, default=None):
data = super(PurchaseOrderCustom, self).copy(default)
data.email_to_vendor = False
@ -85,7 +72,7 @@ class PurchaseOrderCustom(models.Model):
def _prepare_invoice(self):
res = super(PurchaseOrderCustom, self)._prepare_invoice()
res.update({'purchase_id': self.id})
res.update({'purchase_id': self.id, 'res_id': self.id,'res_model': 'purchase.order'})
return res
@api.onchange('type')