0
votes

How can i merge Two integer numbers from fields into One field.

Ex:

work1_name = fields.Many2one('work1.model',string='Work1 Name')
field1 = fields.Integer(related='work1_name.work1_id',string='Work1 ID')

work2_name = fields.Many2one('work2.model',string='Work2 Name')
field2 = fields.Integer(related='work2_name.work2_id',string='Work2 ID')

Need to get the value of field3 = field1 & field2

if field1 = 12 and field2 = 20 then field3= 1220


Tried this but getting errors:

    @api.depends("field1","field2")
    def _comp_bondid(self):
        self.bondid = (self.field1 or "")+" "+(self.field2 or "")

    bondid = fields.Char(compute="_comp_bondid", store=True)  

Thank you for your help <3

1

1 Answers

0
votes

UPDATE FIX

OLD:

@api.depends("field1","field2")
def _comp_bondid(self):
    self.bondid = (self.field1 or "")+" "+(self.field2 or "")

bondid = fields.Char(compute="_comp_bondid", store=True)  

NEW: (ADDING str before the self.fields )

 @api.depends("field1","field2")
 def _comp_bondid(self):
     self.bondid = str(self.field1 or "")+" "+str(self.field2 or "")
    
 bondid = fields.Char(compute="_comp_bondid", store=True)