Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
4077 Vizualizări

I'm a Odoo v.13 CE user (not developer). I have a custom module that have many bugs, I'm trying to understand how fix bug, but I don't find solution.

Module, by barcode scanning in a custom field, add product line in Order with Product, Description, Qty, Unit price, and taxes. If same product barcode is scanned more time, is increase quantity in same product line.   Bugs are: 

1. In Purchase order, is not call correct Price_unit of supplier selected. It apply price 0 always.

2. In Sale order, is not call correct Price_unit of Pricelist selected, It apply default list_price always.

Please, someone can help me to fix this, and say me correct code to add? I'm not a developer, I don't know nothing about code and programming.

Thanks

----------Purchase Order code

def _add_product(self, product, qty, price):
"""Add line or update qty and price based on barcode."""
corresponding_line = self.order_line.filtered(lambda r: r.product_id.id == product.id)
taxes = product.supplier_taxes_id.filtered(lambda t: t.company_id.id == self.company_id.id)
taxes_ids = taxes.ids
if corresponding_line:
corresponding_line[0].product_qty += float(qty)
corresponding_line[0].price_unit = float(price) or product.price
if self.partner_id and self.fiscal_position_id:
taxes_ids = self.fiscal_position_id.map_tax(taxes, product, self.partner_id).ids
else:
self.order_line += self.order_line.new({
'product_id': product.id,
'product_qty': qty,
'date_planned': fields.Datetime.to_string(datetime.datetime.now() - dateutil.relativedelta.relativedelta(months=1)),
'name': product.name,
'product_uom': product.uom_id.id,
'price_unit': float(price) or product.price,
'taxes_id': [(6, 0, taxes_ids)],
})
return True

----------Sale Order code

def _add_product(self, product, qty, price):
"""Add line or update qty and price based on barcode."""
corresponding_line = self.order_line.filtered(lambda r: r.product_id.id == product.id)
taxes = product.taxes_id.filtered(lambda t: t.company_id.id == self.company_id.id)
taxes_ids = taxes.ids
if corresponding_line:
corresponding_line[0].product_uom_qty += float(qty)
corresponding_line[0].price_unit = float(price) or product.list_price
if self.partner_id and self.fiscal_position_id:
taxes_ids = self.fiscal_position_id.map_tax(taxes, product, self.partner_id).ids
else:
self.order_line += self.order_line.new({
'product_id': product.id,
'product_uom_qty': qty,
'name': product.name,
'product_uom': product.uom_id.id,
'price_unit': float(price) or product.list_price,
'tax_id': [(6, 0, taxes_ids)],
})

return True
Imagine profil
Abandonează
Autor Cel mai bun răspuns

"You can try to update dictionary using onchange method of product."

Hi Krutarth. thanks for your help. I'm not a developer, so I don't understand very well generic suggestion, it's more appreciate if you can write code.

Anyway, I've tried in Purchase Order code, to add:

@api.onchange('product')

before code

def _add_product(self, product, qty, price):

if you mean this, but is not change nothing. In purchase order supplier price is always 0

Thanks


Imagine profil
Abandonează
Cel mai bun răspuns

Hi Daniele,

You can try to update dictionary using onchange method of product.

Thanks,

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
mai 22
2087
1
aug. 18
8555
1
sept. 24
1727
0
mar. 23
2795
1
mai 25
1414