Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet

We separated the product name and it's description on devices so it looks like this:

Product Name
Product Description
...
Price
Some Product
Some Product
Some Product Description

...

As you can see the product's name "Some Product" is duplicated in the name-column.


I copied the function's head from account/account_invoice.py

I'm trying with a custom module, which looks like this:

# -*- coding: utf-8 -*-
from openerp import models
class account_invoice_line(models.Model):
_inherit='account.invoice.line'
@api.multi
def product_id_change(self, product, uom_id, qty=0, name='', type='out_invoice',
partner_id=False, fposition_id=False, price_unit=False, currency_id=False,
company_id=None):
res = super(account_invoice_line, self).product_id_change(
product, uom_id, qty=qty, name=name, type=type, partner_id=partner_id,
fposition_id=fposition_id, price_unit=price_unit,
currency_id=currency_id, context=context, company_id=company_id)
if product_id:
product_obj = self.pool.get('product.product')
product = product_obj.browse(cr, uid, product_id, context=context)
if product.description_sale:
res['value']['name'] = product.description_sale
elif product.description_purchase:
res['value']['name'] = product.description_purchase
return res


After installing and trying to create an invoice position, I get this error, which I am not able to fix:

TypeError: product_id_change() got multiple values for keyword argument 'qty'
Avatar
Verwerfen
Autor Beste Antwort

I noticed that this seemed to because by another module of mine, which I now have merged with this one. The module looks like this:

from openerp import models, fields, api
class invoice_city(models.Model):
_inherit = 'account.invoice'
city = fields.Char(string='City', related='partner_id.city')
invoice_by = fields.Selection(string='Invoice by', related='partner_id.x_invoice_by', store=True)
class account_invoice_line(models.Model):
_inherit='account.invoice.line'
@api.multi
def product_id_change(self, product, uom_id, qty=0, name='', type='out_invoice',
partner_id=False, fposition_id=False, price_unit=False, currency_id=False,
company_id=None):
res = super(account_invoice_line, self).product_id_change(
product, uom_id, qty=qty, name=name, type=type, partner_id=partner_id,
fposition_id=fposition_id, price_unit=price_unit,
currency_id=currency_id, context=context, company_id=company_id)
if product_id:
product_obj = self.pool.get('product.product')
product = product_obj.browse(cr, uid, product_id, context=context)
if product.description_sale:
res['value']['name'] = product.description_sale
elif product.description_purchase:
res['value']['name'] = product.description_purchase
return res
However, I still get an error:
TypeError: product_id_change() takes at most 11 arguments (15 given)


Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
1
März 15
4938
3
Dez. 16
7506
3
Apr. 15
3836
3
März 15
5013
1
März 15
14298