From f2e086066b75af0a54ab4f5e60545bf52257c27f Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Thu, 26 May 2016 23:25:20 +0200 Subject: [PATCH] [FIX] Few remarks from Virgine and Nicolas --- beesdoo_coda/__init__.py | 3 ++- beesdoo_coda/models/__init__.py | 1 + beesdoo_coda/models/bank_statement.py | 12 ++++++++++++ beesdoo_product/data/product_label.xml | 4 ++++ beesdoo_product/models/beesdoo_product.py | 24 +++++++++++------------ beesdoo_product/views/beesdoo_product.xml | 1 + 6 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 beesdoo_coda/models/__init__.py create mode 100644 beesdoo_coda/models/bank_statement.py diff --git a/beesdoo_coda/__init__.py b/beesdoo_coda/__init__.py index afcfb68..7e87581 100644 --- a/beesdoo_coda/__init__.py +++ b/beesdoo_coda/__init__.py @@ -1,2 +1,3 @@ # -*- coding: utf-8 -*- -import wizard \ No newline at end of file +import wizard +import models \ No newline at end of file diff --git a/beesdoo_coda/models/__init__.py b/beesdoo_coda/models/__init__.py new file mode 100644 index 0000000..df187ff --- /dev/null +++ b/beesdoo_coda/models/__init__.py @@ -0,0 +1 @@ +import bank_statement \ No newline at end of file diff --git a/beesdoo_coda/models/bank_statement.py b/beesdoo_coda/models/bank_statement.py new file mode 100644 index 0000000..3cc13fe --- /dev/null +++ b/beesdoo_coda/models/bank_statement.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +''' +Created on 16 mai 2016 + +@author: Thibault Francois (thibault@françois.be) +''' +from openerp import models, fields + +class BankStatement(models.Model): + _inherit = 'account.bank.statement' + + coda_note = fields.Text() diff --git a/beesdoo_product/data/product_label.xml b/beesdoo_product/data/product_label.xml index 20b123a..530c946 100644 --- a/beesdoo_product/data/product_label.xml +++ b/beesdoo_product/data/product_label.xml @@ -61,5 +61,9 @@ delivery #ff4000 + + Consignes + + diff --git a/beesdoo_product/models/beesdoo_product.py b/beesdoo_product/models/beesdoo_product.py index c8d0e02..2ddc770 100644 --- a/beesdoo_product/models/beesdoo_product.py +++ b/beesdoo_product/models/beesdoo_product.py @@ -13,12 +13,13 @@ class BeesdooProduct(models.Model): main_seller_id = fields.Many2one('res.partner', compute='_compute_main_seller_id', store=True) - display_unit = fields.Many2one('product.uom', required=True, default=lambda self: self.env.ref('product.product_uom_kgm')) - default_reference_unit = fields.Many2one('product.uom', required=True, default=lambda self: self.env.ref('product.product_uom_kgm')) + display_unit = fields.Many2one('product.uom') + default_reference_unit = fields.Many2one('product.uom') display_weight = fields.Float(compute='_get_display_weight', store=True) - total_with_vat = fields.Float(compute='_get_total_with_vat', store=True) - total_with_vat_by_unit = fields.Float(compute='_get_total_with_vat_by_unit', store=True) + total_with_vat = fields.Float(compute='_get_total', store=True, string="Total Sales Price with VAT") + total_with_vat_by_unit = fields.Float(compute='_get_total', store=True, string="Total Sales Price with VAT by Reference Unit") + total_deposit = fields.Float(compute='_get_total', store=True, string="Deposit Price") @api.one @api.depends('seller_ids', 'seller_ids.date_start') @@ -28,15 +29,12 @@ class BeesdooProduct(models.Model): self.main_seller_id = sellers_ids and sellers_ids[0].name or False @api.one - @api.depends('taxes_id', 'list_price') - def _get_total_with_vat(self): - tax_amount_sum = sum([tax.amount for tax in self.taxes_id]) - self.total_with_vat = self.list_price * (100.0 + tax_amount_sum) / 100 - - @api.one - @api.depends('total_with_vat', 'display_weight', 'weight') - def _get_total_with_vat_by_unit(self): - print self.display_weight, self.total_with_vat, self.weight + @api.depends('taxes_id', 'list_price', 'taxes_id.amount', 'taxes_id.tax_group_id', 'total_with_vat', 'display_weight', 'weight') + def _get_total(self): + consignes_group = self.env.ref('beesdoo_product.consignes_group_tax') + tax_amount_sum = sum([tax._compute_amount(self.list_price, self.list_price) for tax in self.taxes_id if tax.tax_group_id != consignes_group]) + self.total_deposit = sum([tax._compute_amount(self.list_price, self.list_price) for tax in self.taxes_id if tax.tax_group_id == consignes_group]) + self.total_with_vat = self.list_price + tax_amount_sum if self.display_weight > 0: self.total_with_vat_by_unit = self.total_with_vat / self.weight diff --git a/beesdoo_product/views/beesdoo_product.xml b/beesdoo_product/views/beesdoo_product.xml index 40b22b0..6b87f5e 100644 --- a/beesdoo_product/views/beesdoo_product.xml +++ b/beesdoo_product/views/beesdoo_product.xml @@ -31,6 +31,7 @@ +