Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
4200 Zobrazení

I try to add a field in treeview account_invoice_line in invoice which compute and display VAT price per account_invoice_line (1). It's done but when try to recompute total tax (2), the VAT price per line is recompute to 0 (Except for line create in sale.order)



Have you an idea for VAT prices are good for all account.invoice.line 


My code : 

class cap_account_invoice_line(osv.osv):

_inherit = 'account.invoice.line'

_columns = {

'price_with_tax':fields.float(string='Prix TTC', store=True, readonly=True,),

}

@api.multi

def product_id_change(self, product, account_id, uom_id, qty=0, name='', type_x='out_invoice',

partner_id=False, fposition_id=False, price_unit=False, currency_id=False, company_id=None,context = None):

if context is None:

context = {}

if partner_id:

res = super(cap_account_invoice_line, self).product_id_change(product, uom_id, qty=qty, name=name, type=type_x,

partner_id=partner_id, fposition_id=fposition_id, price_unit=price_unit, currency_id=currency_id,

company_id=company_id)

if res == 0:

return res

context = self._context

company_id = company_id if company_id is not None else context.get('company_id', False)

self = self.with_context(company_id=company_id, force_company=company_id)

part = self.env['res.partner'].browse(partner_id)

product = self.env['product.product'].browse(product)

fpos = self.env['account.fiscal.position'].browse(fposition_id)

if type in ('out_invoice', 'out_refund'):

account = product.property_account_income or product.categ_id.property_account_income_categ

else:

account = product.property_account_expense or product.categ_id.property_account_expense_categ

account = fpos.map_account(account)

if type in ('out_invoice', 'out_refund'):

taxes = product.taxes_id or account.tax_ids

else:

taxes = product.supplier_taxes_id or account.tax_ids

taxes = fpos.map_tax(taxes)

taxes.ids

values = res['value']

price = values.get('price_unit', 0) * (1 - values.get('discount', 0) / 100.0)

taxes = values.get('invoice_line_tax_id')

taxes = self.env['account.tax'].browse(taxes)

tax_res = taxes.compute_all(price, qty,product=product, partner=part)

values['price_with_tax'] = tax_res['total_included']

res['value'] = values

return res

@api.multi

def uos_id_change(self, product, uom, qty=0, name='', type_x='out_invoice', partner_id=False,

fposition_id=False, price_unit=False, currency_id=False, company_id=None):

if uom:

super(cap_account_invoice_line, self).uos_id_change(product, uom, qty, name, type_x, partner_id, fposition_id, price_unit, currency_id, company_id)





Avatar
Zrušit
Nejlepší odpověď

Hi,

While you recompute the invoice, did you make sure your vat price is already affecting the price_subtotal of the invoice line?

Logically, your new field should affect the calculations of the field subtotal. And that subtotal will affect the other float fields of the invoice.

Hope this helps.

Thanks.

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
pro 15
5169
0
zář 15
5787
0
bře 25
1419
0
led 25
3496
1
srp 23
14863