diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index 93a6dbf4ea0..98a104ec69d 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -172,5 +172,11 @@ 4 + + + Taxes + 0 + + diff --git a/addons/account/models/account.py b/addons/account/models/account.py index fd4ca55de1e..7fe329f41ce 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -429,6 +429,10 @@ class AccountTax(models.Model): _description = 'Tax' _order = 'sequence' + @api.model + def _default_tax_group(self): + return self.env['account.tax.group'].search([], limit=1) + name = fields.Char(string='Tax Name', required=True, translate=True) type_tax_use = fields.Selection([('sale', 'Sales'), ('purchase', 'Purchases'), ('none', 'None')], string='Tax Scope', required=True, default="sale", help="Determines where the tax is selectable. Note : 'None' means a tax can't be used by itself, however it can still be used in a group.") @@ -451,6 +455,7 @@ class AccountTax(models.Model): help="If set, taxes which are computed after this one will be computed based on the price tax included.") analytic = fields.Boolean(string="Include in Analytic Cost", help="If set, the amount computed by this tax will be assigned to the same analytic account as the invoice line (if any)") tag_ids = fields.Many2many('account.account.tag', 'account_tax_account_tag', string='Tags', help="Optional tags you may want to assign for custom reporting") + tax_group_id = fields.Many2one('account.tax.group', string="Tax Group", default=_default_tax_group, required=True) _sql_constraints = [ ('name_company_uniq', 'unique(name, company_id)', 'Tax names must be unique !'), @@ -649,3 +654,11 @@ class AccountOperationTemplate(models.Model): @api.onchange('name') def onchange_name(self): self.label = self.name + + +class AccountTaxGroup(models.Model): + _name = 'account.tax.group' + _order = 'sequence asc' + + name = fields.Char(required=True, translate=True) + sequence = fields.Integer(default=10) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 5f47ace3562..69128aa25d9 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -7,6 +7,7 @@ from dateutil.relativedelta import relativedelta from openerp import api, fields, models, _ from openerp.tools import float_is_zero +from openerp.tools.misc import formatLang from openerp.exceptions import UserError, RedirectWarning @@ -949,6 +950,18 @@ class AccountInvoice(models.Model): return 'account.mt_invoice_created' return super(AccountInvoice, self)._track_subtype(init_values) + @api.multi + def _get_tax_amount_by_group(self): + self.ensure_one() + res = {} + currency = self.currency_id or self.company_id.currency_id + for line in self.tax_line_ids: + res.setdefault(line.tax_id.tax_group_id, 0.0) + res[line.tax_id.tax_group_id] += line.amount + res = sorted(res.items(), key=lambda l: l[0].sequence) + res = map(lambda l: (l[0].name, formatLang(self.env, l[1], currency_obj=currency)), res) + return res + class AccountInvoiceLine(models.Model): _name = "account.invoice.line" diff --git a/addons/account/security/ir.model.access.csv b/addons/account/security/ir.model.access.csv index ed5d7025350..31aa8dc143e 100644 --- a/addons/account/security/ir.model.access.csv +++ b/addons/account/security/ir.model.access.csv @@ -73,3 +73,7 @@ access_account_payment_method,account.payment.method,model_account_payment_metho access_account_payment,account.payment,model_account_payment,account.group_account_invoice,1,1,1,1 access_account_cashbox,account.bank.statement.cashbox,model_account_bank_statement_cashbox,account.group_account_user,1,1,1,1 access_account_cashbox_line,account.bank.statement.cashbox.line,model_account_cashbox_line,account.group_account_user,1,1,1,1 +access_account_tax_group_internal_user,account.tax.group internal user,model_account_tax_group,base.group_user,1,0,0,0 +access_account_tax_group,account.tax.group,model_account_tax_group,account.group_account_invoice,1,0,0,0 +access_account_tax_group_manager,account.tax.group,model_account_tax_group,account.group_account_manager,1,1,1,1 +access_account_tax_group_sale_manager,account.tax.group sale manager,model_account_tax_group,base.group_sale_salesman,1,0,0,0 diff --git a/addons/account/views/account_view.xml b/addons/account/views/account_view.xml index fa15efda0db..3c5f81686c5 100644 --- a/addons/account/views/account_view.xml +++ b/addons/account/views/account_view.xml @@ -848,8 +848,9 @@