Odoo Help

Welcome!

This community 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.

0

How to get rid of the product name in account.invoice.line.name?

By
Malte Jörgens
on 4/5/16, 5:13 AM 289 views

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'
0
Malte Jörgens
On 4/5/16, 8:16 AM

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)


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/5/16, 5:13 AM
Seen: 289 times
Last updated: 4/5/16, 8:16 AM