简体   繁体   English

Odoo 10调用旧API方法

[英]Odoo 10 call old api method

I am using Odoo 10 and trying override stock quants_get_preferred_domain method. 我正在使用Odoo 10并尝试覆盖股票quants_get_preferred_domain方法。

My code: 我的代码:

@api.v7
def quants_get_preferred_domain(self, cr, uid, qty, move, ops=False,  lot_id=False, domain=None, preferred_domain_list=[], context=None):

And I am getting an error: 我收到一个错误:

  File "/opt/odoo10/addons/stock/models/stock_move.py", line 660, in action_assign
    quants = Quant.quants_get_preferred_domain(qty, move, domain=main_domain[move.id], preferred_domain_list=[])
TypeError: quants_get_preferred_domain() takes at least 5 arguments (5 given)

What can be wring with decorators and how correctly on v10 can I call old api method? 装饰器可以解决什么问题,在v10上如何正确调用旧的api方法?

Seems that you are changing the method decorator definition from @api.model to @api.v7 似乎您正在将方法装饰器定义从@api.model@api.v7

You could check that in the code of the method quants_get_preferred_domain . 您可以在quants_get_preferred_domain方法的代码中进行检查 You should be ok defining the method override as: 您应该可以将方法重写定义为:

@api.model
def quants_get_preferred_domain(self, qty, move, ops=False, lot_id=False, domain=None, preferred_domain_list=[]):

You should also check if your Odoo version is outdated that may have some issues solved in earlier Odoo 10 versions 您还应该检查您的Odoo版本是否已过时,从而可能在早期的Odoo 10版本中解决了一些问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM