تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
4774 أدوات العرض

Then I create some fields of selection type this WARNING appear for every field . 


I have this table as header... 


class FreightSettlement(models.Model):
_name = 'freight.settlement'
_description = 'Freight Settlement'

name = fields.Char(string="Name")
invoice_ids = fields.One2many("freight.settlement.invoice", "parent_id", string="Freight Settlement Invoice")
state = fields.Selection(
[
('draft', 'Draft'),
('done', 'Done'),
], default='draft', string='State'
)

And this as detail... 


class FreightSettlementInvoice(models.Model):
_name = "freight.settlement.invoice"
_description = "Freight Settlement Invoice"

parent_id = fields.Many2one("freight.settlement", string="Freight Settlement")
parent_state = fields.Selection(
[
('draft', 'Draft'),
('done', 'Done'),
], related='parent_id.state', string='State'
)


Then in the server log I get this WARNING. 


2022-07-25 20:16:59,929 1 WARNING staging-data-2 odoo.fields: freight.settlement.invoice.parent_state: selection attribute will be ignored as the field is related


How to solve this WARNING?


Thanks in advance





















الصورة الرمزية
إهمال
أفضل إجابة

Hi,

In the  frieght.settlement.invoice model, define the field parent_state as follows:

parent_state = fields.Selection(related='parent_id.state', string='State' )


Thanks

الصورة الرمزية
إهمال
أفضل إجابة

Hi !
you have created two select boxes, one is linked to the other, and in both places you have specified select options.
You just have to remove options from second Class.
Like this .

class FreightSettlement(models.Model):
_name = 'freight.settlement'
_description = 'Freight Settlement'

name = fields.Char(string="Name")
invoice_ids = fields.One2many("freight.settlement.invoice", "parent_id", string="Freight Settlement Invoice")
state = fields.Selection(
[
('draft', 'Draft'),
('done', 'Done'),
], default='draft', string='State'
)

class FreightSettlementInvoice(models.Model):
_name = "freight.settlement.invoice"
_description = "Freight Settlement Invoice"

parent_id = fields.Many2one("freight.settlement", string="Freight Settlement")
parent_state = fields.Selection(related='parent_id.state', string='State')


Have to write like this
parent_state = fields.Selection(related='parent_id.state', string='State')


الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
أغسطس 23
2392
1
يوليو 23
2546
0
يوليو 23
2211
1
يوليو 23
2100
0
يوليو 23
1999