This question has been flagged
2 Replies
2443 Views

Why it is false, this is the code

from import,
import
from time, date, time
from odoo.addons.base import

class AccountInvoice (models.Model)
_inherit = 'account.invoice'

backorder_id fields.Many2one = ('stock .picking' 'Back Order of' required = True )
date_invoice = fields.Date ("Invoices:")


@ api.multi
def _write (self, vals):
res = super (AccountInvoice, self) ._ write (vals)
print ("Min_Date:", self. backorder_id.min_date )
print ('=============================')
print ("Invoice:" + self.date_invoice)
return res


This code returns False, i want to get the date value of min_date but what I get is the boolean value False?

Thank u again

Avatar
Discard
Author Best Answer

Hi Oliver, I'm still studying about Odoo and this is my task for for start but I still find hard the flow of Odoo :(  It is soo confusing , especially if I'm developing a module not from the scratch


I tried your code and it still returns False. Is it really returns a False value or it will return the actual value of the field I called using the many2one field?

Avatar
Discard
Best Answer

Has so much mistakes in your code.

Learn the coding before start developing.

Try this code and tell me what is happening.

from odoo import models, fields, api


class AccountInvoice(models.Model):
_inherit = 'account.invoice'

backorder_id = fields.Many2one('stock.picking', 'Back Order of', required=True)
date_invoice = fields.Date("Invoices:")

@api.multi
def _write(self, vals):
res = super(AccountInvoice, self)._write(vals)
print("Scheduled Date:", str(self.backorder_id.scheduled_date))
print("Min Date:", str(self.backorder_id.min_date))
print("Invoice:" + str(self.date_invoice))
return res


Avatar
Discard