From a57592abe4e8ac3bac04cbd19eeac88a163aaf7e Mon Sep 17 00:00:00 2001 From: Kinjal Mehta Date: Mon, 18 Jan 2016 16:52:13 +0530 Subject: [PATCH] [IMP] analytic: Replaced account_type field by active field Currently there is a selection field 'account_type' on the account.analytic.account model with 2 values : Active or Archived Let's use an active field instead and add a Archive stat button on the form. That way, we can remove all the domain ('account_type','=','normal') which are implicit with the generic active field behavior --- addons/account/models/account.py | 4 ++-- .../src/js/account_reconciliation_widgets.js | 1 - addons/account/views/account_analytic_view.xml | 2 +- addons/account/views/account_invoice_view.xml | 10 +++++----- addons/account/views/account_view.xml | 8 ++++---- addons/account/wizard/account_reconcile.py | 2 +- .../models/account_analytic_default.py | 2 +- addons/account_asset/account_asset.py | 2 +- addons/account_budget/account_budget.py | 2 +- addons/account_voucher/account_voucher_view.xml | 4 ++-- .../voucher_sales_purchase_view.xml | 4 ++-- addons/analytic/data/analytic_account_demo.xml | 14 -------------- addons/analytic/models/analytic.py | 5 +---- addons/analytic/views/analytic_view.xml | 11 +++++++---- addons/hr_expense/models/hr_expense.py | 2 +- addons/hr_payroll_account/hr_payroll_account.py | 4 ++-- addons/mrp/mrp.py | 4 ++-- addons/purchase/purchase.py | 2 +- .../purchase_requisition/purchase_requisition.py | 4 ++-- addons/sale/sale.py | 2 +- 20 files changed, 37 insertions(+), 52 deletions(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index ed8286fb78f..c84c7d06911 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -714,7 +714,7 @@ class AccountOperationTemplate(models.Model): ], required=True, default='percentage') amount = fields.Float(digits=0, required=True, default=100.0, help="Fixed amount will count as a debit if it is negative, as a credit if it is positive.") tax_id = fields.Many2one('account.tax', string='Tax', ondelete='restrict', domain=[('type_tax_use', '=', 'purchase')]) - analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', ondelete='set null', domain=[('account_type', '=', 'normal')]) + analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', ondelete='set null') second_account_id = fields.Many2one('account.account', string='Account', ondelete='cascade', domain=[('deprecated', '=', False)]) second_journal_id = fields.Many2one('account.journal', string='Journal', ondelete='cascade', help="This field is ignored in a bank statement reconciliation.") @@ -725,7 +725,7 @@ class AccountOperationTemplate(models.Model): ], string='Amount type', required=True, default='percentage') second_amount = fields.Float(string='Amount', digits=0, required=True, default=100.0, help="Fixed amount will count as a debit if it is negative, as a credit if it is positive.") second_tax_id = fields.Many2one('account.tax', string='Tax', ondelete='restrict', domain=[('type_tax_use', '=', 'purchase')]) - second_analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', ondelete='set null', domain=[('account_type', '=', 'normal')]) + second_analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', ondelete='set null') @api.onchange('name') def onchange_name(self): diff --git a/addons/account/static/src/js/account_reconciliation_widgets.js b/addons/account/static/src/js/account_reconciliation_widgets.js index 224fe0449c4..5491f2fddee 100644 --- a/addons/account/static/src/js/account_reconciliation_widgets.js +++ b/addons/account/static/src/js/account_reconciliation_widgets.js @@ -157,7 +157,6 @@ var abstractReconciliation = Widget.extend(ControlPanelMixin, { relation: "account.analytic.account", string: _t("Analytic Acc."), type: "many2one", - domain: [['account_type', '=', 'normal']], }, }, }; diff --git a/addons/account/views/account_analytic_view.xml b/addons/account/views/account_analytic_view.xml index bbfe2d001f2..d8655b9b0a5 100644 --- a/addons/account/views/account_analytic_view.xml +++ b/addons/account/views/account_analytic_view.xml @@ -68,7 +68,7 @@ name="Analytic Accounts" parent="menu_finance_entries" action="analytic.action_analytic_account_form" - id="view_account_analytic_account_list" + id="menu_action_analytic_account_tree2" sequence="30" groups="analytic.group_analytic_accounting"/> - + @@ -108,7 +108,7 @@ - + @@ -265,7 +265,7 @@ + domain="[('company_id', '=', parent.company_id)]"/> @@ -288,7 +288,7 @@ - + @@ -403,7 +403,7 @@ + domain="[('company_id', '=', parent.company_id)]"/> diff --git a/addons/account/views/account_view.xml b/addons/account/views/account_view.xml index 13e73bb4671..0382e08a0b5 100644 --- a/addons/account/views/account_view.xml +++ b/addons/account/views/account_view.xml @@ -727,7 +727,7 @@ - + @@ -749,7 +749,7 @@ - + @@ -1036,7 +1036,7 @@ - + @@ -1282,7 +1282,7 @@ domain="['|', ('parent_id', '=', False), ('is_company', '=', True)]"/> - + diff --git a/addons/account/wizard/account_reconcile.py b/addons/account/wizard/account_reconcile.py index da87e01ad93..31cacdec1ed 100644 --- a/addons/account/wizard/account_reconcile.py +++ b/addons/account/wizard/account_reconcile.py @@ -70,7 +70,7 @@ class AccountMoveLineReconcileWriteoff(models.TransientModel): writeoff_acc_id = fields.Many2one('account.account', string='Write-Off account', required=True, domain=[('deprecated', '=', False)]) date_p = fields.Date(string='Date', default=fields.Date.context_today) comment = fields.Char(required=True, default='Write-off') - analytic_id = fields.Many2one('account.analytic.account', string='Analytic Account', domain=[('account_type', '=', 'normal')]) + analytic_id = fields.Many2one('account.analytic.account', string='Analytic Account') @api.multi def trans_rec_addendum(self): diff --git a/addons/account_analytic_default/models/account_analytic_default.py b/addons/account_analytic_default/models/account_analytic_default.py index 68142ca8983..5f07ae08878 100644 --- a/addons/account_analytic_default/models/account_analytic_default.py +++ b/addons/account_analytic_default/models/account_analytic_default.py @@ -11,7 +11,7 @@ class AccountAnalyticDefault(models.Model): _order = "sequence" sequence = fields.Integer(string='Sequence', help="Gives the sequence order when displaying a list of analytic distribution") - analytic_id = fields.Many2one('account.analytic.account', string='Analytic Account', domain=[('account_type', '=', 'normal')]) + analytic_id = fields.Many2one('account.analytic.account', string='Analytic Account') product_id = fields.Many2one('product.product', string='Product', ondelete='cascade', help="Select a product which will use analytic account specified in analytic default (e.g. create new customer invoice or Sales order if we select this product, it will automatically take this as an analytic account)") partner_id = fields.Many2one('res.partner', string='Partner', ondelete='cascade', help="Select a partner which will use analytic account specified in analytic default (e.g. create new customer invoice or Sales order if we select this partner, it will automatically take this as an analytic account)") user_id = fields.Many2one('res.users', string='User', ondelete='cascade', help="Select a user which will use analytic account specified in analytic default.") diff --git a/addons/account_asset/account_asset.py b/addons/account_asset/account_asset.py index a4664840d26..c0dd7b6b1fb 100644 --- a/addons/account_asset/account_asset.py +++ b/addons/account_asset/account_asset.py @@ -14,7 +14,7 @@ class AccountAssetCategory(models.Model): active = fields.Boolean(default=True) name = fields.Char(required=True, index=True, string="Asset Type") - account_analytic_id = fields.Many2one('account.analytic.account', string='Analytic Account', domain=[('account_type', '=', 'normal')]) + account_analytic_id = fields.Many2one('account.analytic.account', string='Analytic Account') account_asset_id = fields.Many2one('account.account', string='Expense Account', required=True, domain=[('internal_type','=','other'), ('deprecated', '=', False)]) account_income_recognition_id = fields.Many2one('account.account', string='Recognition Income Account', domain=[('internal_type','=','other'), ('deprecated', '=', False)], oldname='account_expense_depreciation_id') account_depreciation_id = fields.Many2one('account.account', string='Depreciation Account', required=True, domain=[('internal_type','=','other'), ('deprecated', '=', False)]) diff --git a/addons/account_budget/account_budget.py b/addons/account_budget/account_budget.py index 965b9515b73..228046587b7 100644 --- a/addons/account_budget/account_budget.py +++ b/addons/account_budget/account_budget.py @@ -168,7 +168,7 @@ class crossovered_budget_lines(osv.osv): _description = "Budget Line" _columns = { 'crossovered_budget_id': fields.many2one('crossovered.budget', 'Budget', ondelete='cascade', select=True, required=True), - 'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account', domain=[('account_type', '=', 'normal')]), + 'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'), 'general_budget_id': fields.many2one('account.budget.post', 'Budgetary Position',required=True), 'date_from': fields.date('Start Date', required=True), 'date_to': fields.date('End Date', required=True), diff --git a/addons/account_voucher/account_voucher_view.xml b/addons/account_voucher/account_voucher_view.xml index 87f93216837..549afc73634 100644 --- a/addons/account_voucher/account_voucher_view.xml +++ b/addons/account_voucher/account_voucher_view.xml @@ -86,7 +86,7 @@ - + @@ -105,7 +105,7 @@ on_change="product_id_change(product_id, parent.partner_id, price_unit, company_id, parent.currency_id, parent.voucher_type)" /> - + diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml index 3d6316c5cc2..3f9a2a2a5b7 100644 --- a/addons/account_voucher/voucher_sales_purchase_view.xml +++ b/addons/account_voucher/voucher_sales_purchase_view.xml @@ -85,7 +85,7 @@ on_change="product_id_change(product_id, parent.partner_id, price_unit, company_id, parent.currency_id, parent.voucher_type)" /> - + @@ -201,7 +201,7 @@ on_change="product_id_change(product_id, parent.partner_id, price_unit, company_id, parent.currency_id, parent.voucher_type)" /> - + diff --git a/addons/analytic/data/analytic_account_demo.xml b/addons/analytic/data/analytic_account_demo.xml index 09ddaf96846..5e7478605ee 100644 --- a/addons/analytic/data/analytic_account_demo.xml +++ b/addons/analytic/data/analytic_account_demo.xml @@ -14,74 +14,60 @@ Seagate P2 - normal Millennium Industries - normal CampToCamp - normal Agrolait - normal Asustek - normal Delta PC - normal Spark Systems - normal Nebula - normal Luminous Technologies - normal Desertic - Hispafuentes - normal Think Big Systems - normal Camp to Camp - normal Administrative - normal Commercial & Marketing - normal diff --git a/addons/analytic/models/analytic.py b/addons/analytic/models/analytic.py index e7fbb36f8f6..20b186c51a4 100644 --- a/addons/analytic/models/analytic.py +++ b/addons/analytic/models/analytic.py @@ -44,10 +44,7 @@ class account_analytic_account(models.Model): name = fields.Char(string='Analytic Account', index=True, required=True, track_visibility='onchange') code = fields.Char(string='Reference', index=True, track_visibility='onchange') # FIXME: we reused account_type to implement the closed accounts (feature removed by mistake on release of v9) without modifying the schemas on already released v9, but it would be more clean to rename it - account_type = fields.Selection([ - ('normal', 'Active'), - ('closed', 'Archived') - ], string='State', required=True, default='normal') + active = fields.Boolean('Active', help="If the active field is set to False, it will allow you to hide the account without removing it.", default=True) tag_ids = fields.Many2many('account.analytic.tag', 'account_analytic_account_tag_rel', 'account_id', 'tag_id', string='Tags', copy=True) line_ids = fields.One2many('account.analytic.line', 'account_id', string="Analytic Lines") diff --git a/addons/analytic/views/analytic_view.xml b/addons/analytic/views/analytic_view.xml index c6bea569973..ee769474347 100644 --- a/addons/analytic/views/analytic_view.xml +++ b/addons/analytic/views/analytic_view.xml @@ -76,6 +76,10 @@
+
@@ -93,7 +97,6 @@ - @@ -118,7 +121,7 @@ - + @@ -135,7 +138,7 @@ - + @@ -179,7 +182,7 @@ - + diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index 58bdb9b0f3e..0b06fd5b44a 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -26,7 +26,7 @@ class HrExpense(models.Model): total_amount = fields.Float(string='Total', store=True, compute='_compute_amount', digits=dp.get_precision('Account')) company_id = fields.Many2one('res.company', string='Company', readonly=True, states={'draft': [('readonly', False)]}, default=lambda self: self.env.user.company_id) currency_id = fields.Many2one('res.currency', string='Currency', readonly=True, states={'draft': [('readonly', False)]}, default=lambda self: self.env.user.company_id.currency_id) - analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', states={'post': [('readonly', True)], 'done': [('readonly', True)]}, oldname='analytic_account', domain=[('account_type', '=', 'normal')]) + analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', states={'post': [('readonly', True)], 'done': [('readonly', True)]}, oldname='analytic_account') account_id = fields.Many2one('account.account', string='Account', states={'post': [('readonly', True)], 'done': [('readonly', True)]}, default=lambda self: self.env['ir.property'].get('property_account_expense_categ_id', 'product.category')) department_id = fields.Many2one('hr.department', string='Department', states={'post': [('readonly', True)], 'done': [('readonly', True)]}) description = fields.Text() diff --git a/addons/hr_payroll_account/hr_payroll_account.py b/addons/hr_payroll_account/hr_payroll_account.py index 0951d8b2a94..dca47f6d299 100644 --- a/addons/hr_payroll_account/hr_payroll_account.py +++ b/addons/hr_payroll_account/hr_payroll_account.py @@ -180,7 +180,7 @@ class hr_payslip(osv.osv): class hr_salary_rule(osv.osv): _inherit = 'hr.salary.rule' _columns = { - 'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account', domain=[('account_type', '=', 'normal')]), + 'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account'), 'account_tax_id':fields.many2one('account.tax', 'Tax'), 'account_debit': fields.many2one('account.account', 'Debit Account', domain=[('deprecated', '=', False)]), 'account_credit': fields.many2one('account.account', 'Credit Account', domain=[('deprecated', '=', False)]), @@ -191,7 +191,7 @@ class hr_contract(osv.osv): _inherit = 'hr.contract' _description = 'Employee Contract' _columns = { - 'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account', domain=[('account_type', '=', 'normal')]), + 'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account'), 'journal_id': fields.many2one('account.journal', 'Salary Journal'), } diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 20cd71535cf..7bc85e89315 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -59,10 +59,10 @@ class mrp_workcenter(osv.osv): 'time_stop': fields.float('Time after prod.', help="Time in hours for the cleaning."), 'costs_hour': fields.float('Cost per hour', help="Specify Cost of Work Center per hour."), 'costs_hour_account_id': fields.many2one('account.analytic.account', 'Hour Account', - help="Fill this only if you want automatic analytic accounting entries on production orders.", domain=[('account_type', '=', 'normal')]), + help="Fill this only if you want automatic analytic accounting entries on production orders."), 'costs_cycle': fields.float('Cost per cycle', help="Specify Cost of Work Center per cycle."), 'costs_cycle_account_id': fields.many2one('account.analytic.account', 'Cycle Account', - help="Fill this only if you want automatic analytic accounting entries on production orders.", domain=[('account_type', '=', 'normal')]), + help="Fill this only if you want automatic analytic accounting entries on production orders."), 'costs_general_account_id': fields.many2one('account.account', 'General Account', domain=[('deprecated', '=', False)]), 'resource_id': fields.many2one('resource.resource','Resource', ondelete='cascade', required=True), 'product_id': fields.many2one('product.product','Work Center Product', help="Fill this product to easily track your production costs in the analytic accounting."), diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index ef4c8533485..a1876a46017 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -511,7 +511,7 @@ class PurchaseOrderLine(models.Model): price_tax = fields.Monetary(compute='_compute_amount', string='Tax', store=True) 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', domain=[('account_type', '=', 'normal')]) + account_analytic_id = fields.Many2one('account.analytic.account', string='Analytic Account') 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_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index 8afeb7e93b2..668e7b26b24 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -41,7 +41,7 @@ class purchase_requisition(osv.osv): 'Status', track_visibility='onchange', required=True, copy=False), 'multiple_rfq_per_supplier': fields.boolean('Multiple RFQ per vendor'), - 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic Account', domain=[('account_type', '=', 'normal')]), + 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic Account'), 'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', required=True), } @@ -314,7 +314,7 @@ class purchase_requisition_line(osv.osv): 'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure')), 'requisition_id': fields.many2one('purchase.requisition', 'Call for Tenders', ondelete='cascade'), 'company_id': fields.related('requisition_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True), - 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic Account', domain=[('account_type', '=', 'normal')]), + 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic Account'), 'schedule_date': fields.date('Scheduled Date'), } diff --git a/addons/sale/sale.py b/addons/sale/sale.py index f1ee4505e96..b5eb50994b3 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -115,7 +115,7 @@ class SaleOrder(models.Model): pricelist_id = fields.Many2one('product.pricelist', string='Pricelist', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="Pricelist for current sales order.") currency_id = fields.Many2one("res.currency", related='pricelist_id.currency_id', string="Currency", readonly=True, required=True) - project_id = fields.Many2one('account.analytic.account', 'Analytic Account', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="The analytic account related to a sales order.", copy=False, domain=[('account_type', '=', 'normal')]) + project_id = fields.Many2one('account.analytic.account', 'Analytic Account', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="The analytic account related to a sales order.", copy=False) order_line = fields.One2many('sale.order.line', 'order_id', string='Order Lines', states={'cancel': [('readonly', True)], 'done': [('readonly', True)]}, copy=True)