Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
3628 Vizualizări

In res.partner I added a field : pal_b which relate to collotypes pallet_id.col_lenght. 

When i use this field in other model named Calc, i'm getting an error.

Example is:

class Contact(models.Model):
_inherit = 'res.partner'
_description = ' Relation restrictions and groups'

pallet_id = fields.Many2one(comodel_name='collotypes', String='Logistic Unit')
pal_l = fields.Float(related='pallet_id.col_length', store=True)
pal_b = fields.Float(related='pallet_id.col_width', store=True)

#------------------------------------------------------------------------------
class Calc(models.Model):
_name = 'calc'
_description = 'Module t.b.v. calculation-functions to-do inherit product-templates'

#-----------------------------------------------------------------------------
customer_id = fields.Many2one(comodel_name='res.partner', String="Customer")
pallet_l = fields.Float(compute='_get_pal', string='Pallet lengte', store=True)

# -----------------------------------------------------------------------------
@api.multi
@api.depends('customer_id')
def _get_pal(self):

for mat in self:
customer = mat.customer_id
mat.pallet_l = customer.pal_l

Error is: 

mat.pallet_b = customer.pal_b
AttributeError: 'res.partner' object has no attribute 'pal_b'

What went wrong, can anybody help?

Imagine profil
Abandonează
Cel mai bun răspuns

First : In your case basically the issue is comes because of you have not upgrade your customized module properly and may be with not to restart the odoo server form the terminal after creating your method.

Second: class Contact:

You can inherit the same base model twice or thrice or any number of times, just ensure the class name is different from other, that way inheritance will not be overlapped..

For example

class ResPartner(models.Model):
_inherit = 'res.partner'
...

class ResPartner2(models.Model):
    _inherit = 'res.partner'
...

class ResPartner3(models.Model):

 _inherit = 'res.partner'


Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
apr. 23
6179
3
apr. 17
11507
1
mai 16
9090
0
mai 16
3246
1
apr. 16
9473