Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
4549 Widoki

I have value error in my classname here, what should I do?

from odoo import models,fields,api
from docutils.nodes import field

class AccountInvoices(models.Model):
_inherits = {'stock.picking':'backorder_id','account.invoice':'refund_invoice_id'}

backorder_id = fields.Many2one('stock.picking','Back Order of')
refund_invoice_id = fields.Many2one('account.invoice',string="Invoice for which this invoice is the refund")


@api.depends('backorder_id','refund_invoice_id')
def _write(self, vals):
print(self.backorder_id.min_date)
print('=============================')
print(self.refund_invoice_id.date_invoice)
return super(AccountInvoice,self)._write(vals)


I create a new classname but it doesn't accept it, what will I do to call the two models, I'm trying to fetch the field min_date from stock.picking and field date_invoice from account_invoice,

I tried to use this:


from odoo import models,fields,api
from docutils.nodes import field

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

backorder_id = fields.Many2one('stock.picking','Back Order of')
date_invoice = fields.Date("This is invoices")


@api.depends('backorder_id')
def _write(self, vals):
print(self.backorder_id.min_date)
print('=============================')
print(self.date_invoice)
return super(AccountInvoice,self)._write(vals)


But the value of backorder_id.min_date is False when the actual value is 2019-08-01


Awatar
Odrzuć

Hi Sudhir

Sorry, I dunno when to use each of the decorator and I tried to use the code u gave to me but the self.backorder_id.min_date still returns the False value. Why it still return a bool value? Thank u for correcting me sir :) and thank u again in advance

Najlepsza odpowiedź

How can you use api.depends on _write method? From where did you get this?

_write method must have api.multi and you should call super method first and then check the value of backorder_id.min_date

Try following code:

@api.multi
def _write(self, vals):
res = super(your_class_name, self)._write(vals)
print ("........ ", self.backorder_id.min_date)
return res


Awatar
Odrzuć
Autor Najlepsza odpowiedź

Hi Sudhir

Sorry, I dunno when to use each of the decorator and I tried to use the code to give me the self.backorder_id.min_date still returns the False value. Why does it still return a bool value? Thank u for correcting me sir :) and thank u again in advance


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
5
cze 21
17901
1
lis 19
3692
2
lis 19
10494
4
wrz 19
4947
3
lip 18
3872