mrp.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. # For copyright and license notices, see __openerp__.py file in root directory
  4. ##############################################################################
  5. from openerp import models, api, fields
  6. class MrpBom(models.Model):
  7. _inherit = 'mrp.bom'
  8. @api.one
  9. def _bom_price_total(self):
  10. self.bom_prod_price_total = sum(
  11. [l.bom_prod_price for l in self.bom_line_ids])
  12. @api.one
  13. def _bom_price_unit(self):
  14. self.bom_prod_price_unit = self.bom_prod_price_total / self.product_qty
  15. bom_prod_price_total = fields.Float(
  16. string='Total price',
  17. compute='_bom_price_total')
  18. bom_prod_price_unit = fields.Float(
  19. string='Precio por Unidad',
  20. compute='_bom_price_unit')
  21. class MrpBomLine(models.Model):
  22. _inherit = 'mrp.bom.line'
  23. @api.one
  24. @api.depends('product_id')
  25. def _product_price_total(self):
  26. self.bom_prod_price = self.product_qty * self.product_id.standard_price
  27. bom_prod_price = fields.Float(
  28. string='Product price total',
  29. compute='_product_price_total')