Hi, I want to put on out invoices the name of the corresponding delivery slip .
For this I try to find all the Invoice/delivery slip pairs with the same origin. So that you can choose inside a selection field between the delivery slips.
But self is always account_invoice(). So I never get the active record to compare.
I hope someone can help. I have no Idea where to start with this...
thanks Chris
Code:
https://pastebin.com/uYetfdLu
class inv_text(models.Model):
_name = "account.invoice"
_inherit = "account.invoice"
delivery_ref = fields.Selection(selection='_get_delivery_name',string='Lieferschein')
@api.multi
def _get_delivery_name(self):
delivery_list = []
deliverys = self.env["stock.picking"].search([("origin","=",self.origin)])
for delivery in deliverys:
delivery_list.append((str(delivery.name),str(delivery.name)))
return delivery_list