-
Adding Boolean field in taxes and add those taxes in which the field is true in purchase order.
about 9 years ago
-
almost 10 years ago
Found Solution This is what I want to do
from openerp.osv import osv, fields import openerp.addons.decimal_precision as dp from openerp.tools.float_utils import float_compare
class company(osv.osv): _inherit = 'account.tax' _columns = { 'Tax_Included_In_Costprice': fields.boolean('Tax included in cost price', help="Do cost price include tax?"), }
class purchase_order_line(osv.osv): _inherit = 'purchase.order.line' def _compute_total(self, cr, uid, ids, prop, arg, context=None): res = {} cur_obj=self.pool.get('res.currency') tax_obj = self.pool.get('account.tax') for line in self.browse(cr, uid, ids, context=context): unit_price = line.price_unit if line.item_seller_price != 0: unit_price = line.item_seller_price taxes = tax_obj.compute_all(cr, uid, line.taxes_id, unit_price, line.product_qty, line.product_id, line.order_id.partner_id) cur = line.order_id.pricelist_id.currency_id res[line.id] = cur_obj.round(cr, uid, cur, taxes['total_included']-taxes['total']) return res
1 Answer(s)