You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.2 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Copyright (C) 2015 Aserti Global Solutions (http://www.aserti.es/).
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as published
  8. # by the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. ##############################################################################
  20. from openerp import models, fields, api
  21. class PosOrderLine(models.Model):
  22. _inherit = "pos.order.line"
  23. @api.one
  24. @api.depends('tax_ids', 'qty', 'price_unit',
  25. 'product_id', 'discount', 'order_id.partner_id')
  26. def _amount_line_all(self):
  27. price = self.price_unit * (1 - (self.discount or 0.0) / 100.0)
  28. taxes = self.tax_ids.compute_all(
  29. price, self.qty, product=self.product_id,
  30. partner=self.order_id.partner_id)
  31. self.price_subtotal = taxes['total']
  32. self.price_subtotal_incl = taxes['total_included']
  33. tax_ids = fields.Many2many(
  34. 'account.tax', 'pline_tax_rel', 'pos_line_id', 'tax_id',
  35. "Taxes", domain=[('type_tax_use', '=', 'sale')])
  36. price_subtotal = fields.Float(compute="_amount_line_all", store=True)
  37. price_subtotal_incl = fields.Float(compute="_amount_line_all", store=True)
  38. class PosOrder(models.Model):
  39. _inherit = "pos.order"
  40. @api.model
  41. def _amount_line_tax(self, line):
  42. price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
  43. taxes = line.tax_ids.compute_all(
  44. price, line.qty, product=line.product_id,
  45. partner=line.order_id.partner_id)['taxes']
  46. val = 0.0
  47. for c in taxes:
  48. val += c.get('amount', 0.0)
  49. return val