I'm a Odoo user (not developer). I have a custom module that have a bug, I'm trying to understand how fix bug, but I don't find solution. I think code interested is in model file. Module, by barcode scanning in a custom field, add product line in Order with Product, Description, Qty, Unit price, but missing taxes. If same product barcode is scanned more time, is increase quantity in same product line. Bug issue is Not add product Taxes, so I have a product line without taxes. I've seen inside code, and there is not any command that invokes Taxes.
Please, anyone 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.
------------First code part:
# added the price history map
priceHistory = {}
class SaleOrder(models.Model):
"""Inherit Sale Order."""
_inherit = "sale.order"
barcode = fields.Char(string='Barcode', size=50)
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)
if corresponding_line:
corresponding_line[0].product_uom_qty += float(qty)
corresponding_line[0].price_unit = float(price) or product.list_price
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,
})
return True
------------ Last code part
if product_id: # get the history price if price_position == -1: #if priceHistory.has_key(product_id.id): if product_id.id in priceHistory.keys(): price = priceHistory[product_id.id] self._add_product(product_id, qty, price) self.barcode = barcode = None #save the product price priceHistory[product_id.id] = price return
Here I've tried to add:
'tax_id' : account.tax
belowe line
'price_unit': float(price) or product.list_price,but is not correct, I have error
Thank you very much