Odoo Help

1

0
2 Answers
0
Hendrik
3‏/8‏/2018 1:32 ص

The correct syntax would be:

class BaseModelExtend(models.AbstractModel):
        _name = 'basemodel.extend'
        @api.model_cr
        def _register_hook(self):
                origin_create = models.AbstractModel.create
                @api.model
                @api.returns('self', lambda value: value.id)
                def create(self, vals):
                        res = origin_create(self, vals) 
                       _logger.info("THIS IS OK")
                       return res
                models.AbstractModel.create = create
                return super(BaseModelExtend, self)._register_hook()
0
Omega
26‏/4‏/2018 2:02 م

we have already changed base method name_get, see this it may help.

from openerp.models import BaseModel
from openerp import api

@api.multi
    def name_get(self):
        result = []
       cr, uid, context = self.env.args
       if uid in context.keys():
            user = self.env['res.users'].browse(context.get('uid'))
if user:
for record in self:
result.append(record.name)
               return result
BaseModel.name_get = name_get                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   


Ask a Question
Writer
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now