To create Account Analytic Line to compute the line and inherit the class account_analytic_line in odoo-9 then write this function in .py file in your module in odoo.
Use this code show in given below
def _compute_accountanalytic(self, domain=None):
lines = {}
if not domain:
domain = [('so_line', 'in', self.ids), ('amount', '<=', 0.0)]
data = self.env['account.analytic.line'].read_group(
domain,
['so_line', 'unit_amount', 'product_uom_id'], ['product_uom_id', 'so_line'], lazy=False
)
for d in data:
if not d['product_uom_id']:
continue
line = self.browse(d['so_line'][0])
lines.setdefault(line, 0.0)
uom = self.env['product.uom'].browse(d['product_uom_id'][0])
if line.product_uom.category_id == uom.category_id:
qty = self.env['product.uom']._compute_qty_obj(uom, d['unit_amount'], line.product_uom)
else:
qty = d['unit_amount']
lines[line] += qty
for line, qty in lines.items():
line.qty_delivered = qty
return True
0 Comment(s)