From f439d8dcc78ae67ddd82661ee2698391aaa3348e Mon Sep 17 00:00:00 2001 From: gregoire Date: Sat, 16 Apr 2016 19:09:20 +0200 Subject: [PATCH] add total by unit and clean xml --- beesdoo_product/models/beesdoo_product.py | 14 +++- beesdoo_product/views/beesdoo_product.xml | 78 +---------------------- 2 files changed, 15 insertions(+), 77 deletions(-) diff --git a/beesdoo_product/models/beesdoo_product.py b/beesdoo_product/models/beesdoo_product.py index c613da4..0f851c1 100644 --- a/beesdoo_product/models/beesdoo_product.py +++ b/beesdoo_product/models/beesdoo_product.py @@ -18,22 +18,32 @@ class BeesdooProduct(models.Model): total = fields.Float(compute='get_total') total_with_vat = fields.Float(compute='get_total_with_vat') + total_with_vat_by_unit = fields.Float(compute='get_total_with_vat_by_unit') + @api.one @api.depends('weight', 'display_unit') def get_display_weight(self): if self.display_unit: self.display_weight = self.weight / self.display_unit.factor + @api.one def get_total(self): price_ht = self.env['product.pricelist'].search([])[0].price_get(self.id, 1)[1] self.total = price_ht + @api.one def get_total_with_vat(self): tax_amount_sum = 0.0 - for tax in self.taxes_id: - tax_amount_sum = tax_amount_sum + tax.amount + if hasattr(self, 'taxes_id'): + for tax in self.taxes_id: + tax_amount_sum = tax_amount_sum + tax.amount self.total_with_vat = self.total * (100.0 + tax_amount_sum) / 100 + @api.one + def get_total_with_vat_by_unit(self): + if self.display_weight > 0: + self.total_with_vat_by_unit = self.total_with_vat/self.display_weight + class BeesdooProductLabel(models.Model): _name = 'beesdoo.product.label' diff --git a/beesdoo_product/views/beesdoo_product.xml b/beesdoo_product/views/beesdoo_product.xml index 26e2222..f963803 100644 --- a/beesdoo_product/views/beesdoo_product.xml +++ b/beesdoo_product/views/beesdoo_product.xml @@ -1,63 +1,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bees.product product.template - + - + + - @@ -68,32 +24,4 @@ - - bees.product - product.supplierinfo - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file