I've inherited `res.partner` class, and I have these two methods:
    jour_id = fields.Many2one('account.journal', string='Journal', required=False,
        help="Default journal for damaged invoices")
    acc_id = fields.Many2one('account.account', string='Account', 
        help="Default account used for invoices and lines from damaged invoices")
    printer_fiscal = fields.Boolean(string='Manages fiscal printer',
        help='Indicates that the company can operate a fiscal printer')
    @api.model
    def create(self, vals): 
        """ To create a new record,
        adds a Boolean field to true
        indicates that the partner is a company
        """
        #if context is None:
            #context = {}
        ctx = self._context.copy()
        ctx.update({'create_company': True})
        return super(ResCompany, self).create(vals) 
    @api.model
    def write(self, values): 
        """ To write a new record,
        adds a Boolean field to true
        indicates that the partner is a company
        """
        #if context is None:
            #context = {}
        ctx = self._context.copy()
        ctx.update({'create_company': True})
        return super(ResCompany, self).write(values)
These two fields, are updated or created by these two functions `create` and `write`.
But when I try any of these, by editing the company, it throws me this:
    Traceback (most recent call last):
    File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 638, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
    File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 675, in dispatch
    result = self._call_function(**self.params)
    File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 331, in _call_function
    return checked_call(self.db, *args, **kwargs)
    File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/service/model.py", line 119, in wrapper
    return f(dbname, *args, **kwargs)
    File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 324, in checked_call
    result = self.endpoint(*a, **kw)
    File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 933, in __call__
    return self.method(*args, **kw)
    File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 504, in response_wrap
    response = f(*args, **kw)
    File "/home/kristian/odoov10/odoo-10.0rc1c-20161005/odoo/addons/web/controllers/main.py", line 862, in call_kw
    return self._call_kw(model, method, args, kwargs)
    File "/home/kristian/odoov10/odoo-10.0rc1c-20161005/odoo/addons/web/controllers/main.py", line 854, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
    File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/api.py", line 679, in call_kw
    return call_kw_model(method, model, args, kwargs)
    File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/api.py", line 664, in call_kw_model
    result = method(recs, *args, **kwargs)
    TypeError: write() got an unexpected keyword argument 'context'
I think it's because of this `ctx = self._context.copy()` but I've seen other methods on v10 which have it declared this way, I don't know if I should remove it.
Any ideas on this?
Odoo is the world's easiest all-in-one management software.
 It includes hundreds of business apps:
- 客戶關係
- e-Commerce
- 會計
- 庫存
- PoS
- Project
- MRP
此問題已被標幟
            
                2
                
                    回覆
                
            
        
        
            
                35903
                
                    瀏覽次數
                
            
        
    Just change it to this
@api.multi
def write(self, values):
@api.multi  
    def write(self,vals):
        ctx = dict(self._context or {})
        print "===========",ctx
        return super(SaleOrder, self.with_context(ctx)).write(vals)
| 相關帖文 | 回覆 | 瀏覽次數 | 活動 | |
|---|---|---|---|---|
|  | 1 3月 17  | 6815 | ||
|  | 1 3月 17  | 12964 | ||
|  | 1 3月 23  | 6298 | ||
|  | 2 12月 22  | 3415 | ||
|  | 2 10月 15  | 5695 | 
