Skip to Content
Menu
This question has been flagged
1 Reply
2249 Views

I need to access the sale.order an account.move originated from (because I want to put some custom attributes of the sale.order on the invoice report)

Is there already an attribute for this, if so, how can I access it 

and If not what do I have to do to get this connection?

Avatar
Discard
Best Answer

You can create a field in account.move and update its value from sale.order then after you can easily access its value in invoice report. i.e: 

class AccountMove(models.Model):
        _inherit = "account.move"
        delivery_date = fields.Datetime("Delivery Date")


class SaleOrder(models.Model):
        _inherit = "sale.order"
        def _prepare_invoice(self):
                invoice_vals = super(SaleOrder, self)._prepare_invoice()
                invoice_vals['delivery_date'] = self.commitment_date
                return invoice_vals


In this example: i am updating the custom field delivery_date of account.move by using _prepare_invoice() method.



Avatar
Discard
Related Posts Replies Views Activity
0
Nov 24
25
1
Sep 18
2241
1
Aug 18
3623
0
Nov 24
39
2
Nov 24
1799