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.

44 lines
1.6 KiB

  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class BeesdooProduct(models.Model):
  4. _inherit = 'product.template'
  5. eco_label = fields.Many2one('beesdoo.product.label', domain=[('type', '=', 'eco')])
  6. local_label = fields.Many2one('beesdoo.product.label', domain=[('type', '=', 'local')])
  7. fair_label = fields.Many2one('beesdoo.product.label', domain=[('type', '=', 'fair')])
  8. origin_label = fields.Many2one('beesdoo.product.label', domain=[('type', '=', 'delivery')])
  9. display_unit = fields.Many2one('product.uom', required=True)
  10. default_reference_unit = fields.Many2one('product.uom', required=True)
  11. display_weight = fields.Float(compute='get_display_weight')
  12. total = fields.Float(compute='get_total')
  13. total_with_vat = fields.Float(compute='get_total_with_vat')
  14. @api.one
  15. @api.depends('weight', 'display_unit')
  16. def get_display_weight(self):
  17. if self.display_unit:
  18. self.display_weight = self.weight / self.display_unit.factor
  19. def get_total(self):
  20. price_ht = self.env['product.pricelist'].search([])[0].price_get(self.id, 1)[1]
  21. self.total = price_ht
  22. def get_total_with_vat(self):
  23. tax_amount_sum = 0.0
  24. for tax in self.taxes_id:
  25. tax_amount_sum = tax_amount_sum + tax.amount
  26. self.total_with_vat = self.total * (100.0 + tax_amount_sum) / 100
  27. class BeesdooProductLabel(models.Model):
  28. _name = 'beesdoo.product.label'
  29. name = fields.Char()
  30. type = fields.Selection(
  31. [('eco', 'Écologique'), ('local', 'Local'), ('fair', 'Équitable'), ('delivery', 'Distribution')])
  32. color_code = fields.Char()