Odoo Hilfe

1

0
1 Antwort
5
Avatar

Cyril Gaspard (GEM) Frankreich

--Cyril Gaspard (GEM)--
4364
| 6 6 10
Paris, Frankreich
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Rank #1 on first OpenERP forum

OpenERP award "Top Contributor" 2011, for my actions on forum

Odoo forum moderator


Cyril Gaspard (GEM) Frankreich
02.04.15, 20:16

Hi,

this is an example, but you can override existing function _compute_price used by the field price_subtotal ...


from openerp import api, models, fields

import openerp.addons.decimal_precision as dp



class AccountInvoiceLine(models.Model):

     _inherit = 'account.invoice.line'


     price_subtotal_tax = fields.Float(compute='_compute_price_tax', string=' Total including tax', digits= dp.get_precision('Product Price'), store=True)


    

    @api.one

     @api.depends('price_unit', 'discount', 'invoice_line_tax_id', 'quantity',

         'product_id', 'invoice_id.partner_id', 'invoice_id.currency_id')

     def _compute_price_tax(self):

         price = self.price_unit * (1 - (self.discount or 0.0) / 100.0)

         taxes = self.invoice_line_tax_id.compute_all(price, self.quantity, product=self.product_id,

                                                                                  partner=self.invoice_id.partner_id)

         self.price_subtotal_tax = taxes['total_included']

         if self.invoice_id:

             self.price_subtotal_tax = self.invoice_id.currency_id.round(self.price_subtotal_tax)


Bye

1 Kommentar
Victor Godayer Frankreich
03.04.15, 03:21

Thanks a lot, it works like a charm, and understood the logic, so I did the same one sale_order_line!

Fragen Sie
Writer
Stichwörter
Keep Informed
1 Verfolger
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now