Override a method & append new items to an existing dictionary Odoo13

Viewed 48

I have overridden a method to append some new items to the dictionary of the original method. when I execute my code I have this error:

'bool' object has no attribute 'dict_one'

but the original method has that attribute here is my code:

    def action_transaction_done(self):
        res = super(ProjectTransaction, self).action_transaction_done()

        res.dict_one['branch_id'] = self.branch_id.id
        return res

and this the orginal method code:

    def action_transaction_done(self):

        for action in self:
        
            for line in action.details_by_category:
            
                if self.account_id:
                    dict_one= (0, 0, {
                       'name': line.name,
                       'partner_id': line._get_partner_id(credit_account=False),
                       'account_id': self.account_id,
                       'journal_id': action.journal_id.id,
                       'date': date,
                       #to be added here
                    
                       })
                       return dict_one

I want to append this new item the dict

1 Answers

When account_id (self.account_id) is not set, action_transaction_done will return None, to avoid the none type, check the returned result then add the branch to the returned tuple.

Example:

if res: 
    res[-1]['branch_id'] = self.branch_id.id

The following error:

'bool' object has no attribute 'dict_one'

Is not raised because of the original function.

The method has been overridden in many places, try to check those functions and check which one returns a boolean

Related