Reputation: 10189
I have the following code in a method of the stock.picking
model:
...
for line in picking.move_lines:
if line.procurement_id and line.procurement_id.sale_line_id:
sale_line = line.procurement_id.sale_line_id
_logger.info(sale_line)
cur = sale_line.order_id.pricelist_id.currency_id
price = sale_line._calc_line_base_price()
qty = sale_line._calc_line_quantity()
...
I am checking with the logger that sale_line
variable is a sale.order.line
object -I am getting sale.order.line(14,)-, so I cannot understand why I am getting the following error:
TypeError: _calc_line_base_price() takes at least 4 arguments (4 given)
If I call that method with old API format, it works, but how to call it with new API format?
This answer explains the problem very well, but I think it is not my case as the method I am calling is inside the class of sale.order.line
:
Odoo: _get_state() takes at least 4 arguments (4 given) in xml view
Can anyone explain me this? By the way, I am working with version 8.
Upvotes: 2
Views: 1147
Reputation: 14801
While calling an old style method within a new style method, Odoo tries to wrap the parameters correctly. Problem here is the method _calc_line_base_price
because it can't be wrapped automatically.
def _calc_line_base_price(self, cr, uid, line, context=None):
The parameter line
is unsual for this type of methods (call on one instance, new api would be @api.multi
with a self.ensure_one()
). So you need to call it like a "static" odoo class method:
price = self.env['sale.order.line']._calc_line_base_price(sale_line)
Upvotes: 1