Hi,
I need to override the product_id_change function defined in sale.order.line, so it doesn't change the unit_price every time I update the quantity.
I understand I have to use super, but I'm not sure how it all works.
Can anyone help?
Thank you.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
I need to override the product_id_change function defined in sale.order.line, so it doesn't change the unit_price every time I update the quantity.
I understand I have to use super, but I'm not sure how it all works.
Can anyone help?
Thank you.
Using super() allows to change behavior (returned value or any logic before that) of the method you are super'ing. In this particular case you may find it convenient to replicate all code of the supered method (as it contains significant amount of logic, you dont want to lose it), and only change what is necessary.
To make the change, super the product_id_change() in your module:
class SaleOrderLine(orm.Model):
_inherit = 'sale.order.line'
def product_id_change(
self, cr, uid, ids,
pricelist, product, qty=0,
uom=False, qty_uos=0, uos=False,
name='', partner_id=False,
lang=False, update_tax=True,
date_order=False, packaging=False,
fiscal_position=False, flag=False,
context=None):super(SaleOrderLine, self).product_id_change(
cr, uid, ids, pricelist,
product, qty, uom, qty_uos,
uos, name, partner_id, lang,
update_tax, date_order, packaging=packaging,
fiscal_position=fiscal_position,
flag=flag, context=context)
# Your changes herereturn {'value': result, 'domain': domain, 'warning': warning}
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
Daftar| Post Terkait | Replies | Tampilan | Aktivitas | |
|---|---|---|---|---|
|
Error: [_.sprintf] expecting number but found array
Diselesaikan
|
1
Des 15
|
7815 | ||
|
[v13] Help overriding _display_address
Diselesaikan
|
1
Nov 20
|
3349 | ||
|
4
Des 19
|
8426 | |||
|
1
Mar 16
|
4443 | |||
|
1
Feb 16
|
7370 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.