diff options
| author | qdp-odoo <qdp@odoo.com> | 2016-05-04 09:37:41 +0200 |
|---|---|---|
| committer | qdp-odoo <qdp@odoo.com> | 2016-05-04 09:37:41 +0200 |
| commit | 54b0168d5e7e9c855c4b8e45000f2b32c3fdea75 (patch) | |
| tree | 4680289c52af662424d03358d70dc11a18f6832e | |
| parent | 037e61af32eeb851f90f16bea1477ad4af757667 (diff) | |
[IMP] account, sale, purchase: added analytic tags in SO, PO and invoices, to allow reporting based on those tags
| -rw-r--r-- | addons/account/models/account_invoice.py | 5 | ||||
| -rw-r--r-- | addons/account/models/account_move.py | 7 | ||||
| -rw-r--r-- | addons/account/views/account_invoice_view.xml | 2 | ||||
| -rw-r--r-- | addons/account/views/account_view.xml | 1 | ||||
| -rw-r--r-- | addons/purchase/invoice.py | 1 | ||||
| -rw-r--r-- | addons/purchase/purchase.py | 1 | ||||
| -rw-r--r-- | addons/purchase/purchase_view.xml | 1 | ||||
| -rw-r--r-- | addons/sale/sale.py | 2 | ||||
| -rw-r--r-- | addons/sale/sale_view.xml | 1 |
9 files changed, 21 insertions, 0 deletions
diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index caf6358fcca..cdab5dac0b4 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -630,6 +630,7 @@ class AccountInvoice(models.Model): for child in tax.children_tax_ids: if child.type_tax_use != 'none': tax_ids.append((4, child.id, None)) + analytic_tag_ids = [(4, analytic_tag.id, None) for analytic_tag in line.analytic_tag_ids] move_line_dict = { 'invl_id': line.id, @@ -644,6 +645,7 @@ class AccountInvoice(models.Model): 'account_analytic_id': line.account_analytic_id.id, 'tax_ids': tax_ids, 'invoice_id': self.id, + 'analytic_tag_ids': analytic_tag_ids } if line['account_analytic_id']: move_line_dict['analytic_line_ids'] = [(0, 0, line._get_analytic_line())] @@ -679,6 +681,7 @@ class AccountInvoice(models.Model): invoice_line.get('product_id', 'False'), invoice_line.get('analytic_account_id', 'False'), invoice_line.get('date_maturity', 'False'), + invoice_line.get('analytic_tag_ids', 'False'), ) def group_lines(self, iml, line): @@ -827,6 +830,7 @@ class AccountInvoice(models.Model): 'invoice_id': line.get('invoice_id', False), 'tax_ids': line.get('tax_ids', False), 'tax_line_id': line.get('tax_line_id', False), + 'analytic_tag_ids': line.get('analytic_tag_ids', False), } @api.multi @@ -1104,6 +1108,7 @@ class AccountInvoiceLine(models.Model): string='Taxes', domain=[('type_tax_use','!=','none')], oldname='invoice_line_tax_id') account_analytic_id = fields.Many2one('account.analytic.account', string='Analytic Account') + analytic_tag_ids = fields.Many2many('account.analytic.tag', string='Analytic Tags') company_id = fields.Many2one('res.company', string='Company', related='invoice_id.company_id', store=True, readonly=True) partner_id = fields.Many2one('res.partner', string='Partner', diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 4a0920dfcc9..b99904674e0 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -372,6 +372,7 @@ class AccountMoveLine(models.Model): tax_ids = fields.Many2many('account.tax', string='Taxes') tax_line_id = fields.Many2one('account.tax', string='Originator tax') analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account') + analytic_tag_ids = fields.Many2many('account.analytic.tag', string='Analytic tags') company_id = fields.Many2one('res.company', related='account_id.company_id', string='Company', store=True) counterpart = fields.Char("Counterpart", compute='_get_counterpart', help="Compute the counter part accounts of this journal item for this journal entry. This can be needed in reports.") @@ -1178,6 +1179,12 @@ class AccountMoveLine(models.Model): if context.get('reconcile_date'): domain += ['|', ('reconciled', '=', False), '|', ('matched_debit_ids.create_date', '>', context['reconcile_date']), ('matched_credit_ids.create_date', '>', context['reconcile_date'])] + if context.get('account_tag_ids'): + domain += [('account_id.tag_ids', 'in', context['account_tag_ids'].ids)] + + if context.get('analytic_tag_ids'): + domain += ['|', ('analytic_account_id.tag_ids', 'in', context['analytic_tag_ids'].ids), ('analytic_tag_ids', 'in', context['analytic_tag_ids'].ids)] + where_clause = "" where_clause_params = [] tables = '' diff --git a/addons/account/views/account_invoice_view.xml b/addons/account/views/account_invoice_view.xml index f1d9a95d232..5ac0897df64 100644 --- a/addons/account/views/account_invoice_view.xml +++ b/addons/account/views/account_invoice_view.xml @@ -266,6 +266,7 @@ domain="[('company_id', '=', parent.company_id), ('internal_type', '=', 'other')]"/> <field name="account_analytic_id" groups="analytic.group_analytic_accounting" domain="[('company_id', '=', parent.company_id)]"/> + <field name="analytic_tag_ids" groups="analytic.group_analytic_accounting" widget="many2many_tags"/> <field name="quantity"/> <field name="uom_id" groups="product.group_uom"/> <field name="price_unit"/> @@ -404,6 +405,7 @@ domain="[('company_id', '=', parent.company_id), ('internal_type', '=', 'other')]"/> <field name="account_analytic_id" groups="analytic.group_analytic_accounting" domain="[('company_id', '=', parent.company_id)]"/> + <field name="analytic_tag_ids" groups="analytic.group_analytic_accounting" widget="many2many_tags"/> <field name="quantity"/> <field name="uom_id" groups="product.group_uom"/> <field name="price_unit"/> diff --git a/addons/account/views/account_view.xml b/addons/account/views/account_view.xml index 08be467b7e7..d256503ae55 100644 --- a/addons/account/views/account_view.xml +++ b/addons/account/views/account_view.xml @@ -1078,6 +1078,7 @@ </group> <group groups="analytic.group_analytic_accounting" string="Analytic"> <field name="analytic_account_id"/> + <field name="analytic_tag_ids" widget="many2many_tags"/> </group> </group> <field name="narration" colspan="4" nolabel="1" placeholder="Add an internal note..."/> diff --git a/addons/purchase/invoice.py b/addons/purchase/invoice.py index dbdbbf211a4..a92bf3e8a12 100644 --- a/addons/purchase/invoice.py +++ b/addons/purchase/invoice.py @@ -62,6 +62,7 @@ class AccountInvoice(models.Model): 'quantity': qty, 'discount': 0.0, 'account_analytic_id': line.account_analytic_id.id, + 'analytic_tag_ids': line.analytic_tag_ids.ids, 'invoice_line_tax_ids': invoice_line_tax_ids.ids } account = new_lines.get_invoice_line_account('in_invoice', line.product_id, self.purchase_id.fiscal_position_id, self.env.user.company_id) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 65b9a5d5026..309e5c6bfc4 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -560,6 +560,7 @@ class PurchaseOrderLine(models.Model): order_id = fields.Many2one('purchase.order', string='Order Reference', select=True, required=True, ondelete='cascade') account_analytic_id = fields.Many2one('account.analytic.account', string='Analytic Account') + analytic_tag_ids = fields.Many2many('account.analytic.tag', string='Analytic Tags') company_id = fields.Many2one('res.company', related='order_id.company_id', string='Company', store=True, readonly=True) state = fields.Selection(related='order_id.state', stored=True) diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 026101887f0..c0aa6dcacf4 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -220,6 +220,7 @@ <field name="date_planned"/> <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/> <field name="account_analytic_id" context="{'default_partner_id':parent.partner_id}" groups="purchase.group_analytic_accounting"/> + <field name="analytic_tag_ids" groups="purchase.group_analytic_accounting" widget="many2many_tags"/> <field name="product_qty"/> <field name="qty_received" invisible="not context.get('show_purchase', False)"/> <field name="qty_invoiced" invisible="not context.get('show_purchase', False)"/> diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 02b18df0b69..dccc177b2e9 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -729,6 +729,7 @@ class SaleOrderLine(models.Model): currency_id = fields.Many2one(related='order_id.currency_id', store=True, string='Currency', readonly=True) company_id = fields.Many2one(related='order_id.company_id', string='Company', store=True, readonly=True) order_partner_id = fields.Many2one(related='order_id.partner_id', store=True, string='Customer') + analytic_tag_ids = fields.Many2many('account.analytic.tag', string='Analytic Tags') state = fields.Selection([ ('draft', 'Quotation'), @@ -779,6 +780,7 @@ class SaleOrderLine(models.Model): 'product_id': self.product_id.id or False, 'invoice_line_tax_ids': [(6, 0, self.tax_id.ids)], 'account_analytic_id': self.order_id.project_id.id, + 'analytic_tag_ids': [(6, 0, self.analytic_tag_ids.ids)], } return res diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 96fd5a2f025..a1c868f806d 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -257,6 +257,7 @@ attrs="{'readonly': [('state', 'in', ('sale','done', 'cancel'))]}" context="{'company_id': parent.company_id}" groups="product.group_uom" options='{"no_open": True}'/> + <field name="analytic_tag_ids" groups="analytic.group_analytic_accounting" widget="many2many_tags"/> <field name="price_unit" attrs="{'readonly': [('qty_invoiced', '>', 0)]}"/> <field name="tax_id" widget="many2many_tags" domain="[('type_tax_use','=','sale'),('company_id','=',parent.company_id)]" |
