diff options
| author | Jainik Patel <jaa@odoo.com> | 2016-08-30 09:55:24 +0200 |
|---|---|---|
| committer | qdp-odoo <qdp@odoo.com> | 2016-08-30 09:55:24 +0200 |
| commit | 531ed05a4320c4e8ee9406b3d5ea4f7da2095849 (patch) | |
| tree | 4fc2259f3d30e19ea3bf7fe049428ad9e6ee7966 /addons | |
| parent | a267d8205bf7cabd129a0fea2e7ab5552026b70b (diff) | |
[IMP] account: add bank statement operation presets as template in l10n modules.
In details:
* account.operation.template object renamed into account.reconcile.model
* account.reconcile.model.template object created
* added some records for l10n_be
Was PR 11230
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/account/demo/account_statement_operations.yml | 6 | ||||
| -rw-r--r-- | addons/account/models/account.py | 4 | ||||
| -rw-r--r-- | addons/account/models/chart_template.py | 59 | ||||
| -rw-r--r-- | addons/account/security/account_security.xml | 6 | ||||
| -rw-r--r-- | addons/account/security/ir.model.access.csv | 3 | ||||
| -rw-r--r-- | addons/account/static/src/js/account_reconciliation_widgets.js | 6 | ||||
| -rw-r--r-- | addons/account/views/account_journal_dashboard_view.xml | 2 | ||||
| -rw-r--r-- | addons/account/views/account_view.xml | 24 | ||||
| -rw-r--r-- | addons/l10n_be/__openerp__.py | 3 | ||||
| -rw-r--r-- | addons/l10n_be/data/account_pcmn_belgium_data.xml | 7 | ||||
| -rw-r--r-- | addons/l10n_be/data/account_reconcile_model_template.xml | 32 | ||||
| -rw-r--r-- | addons/l10n_be/data/account_tax_template_data.xml | 13 |
12 files changed, 139 insertions, 26 deletions
diff --git a/addons/account/demo/account_statement_operations.yml b/addons/account/demo/account_statement_operations.yml index 342e35fdac9..e4a87472fa0 100644 --- a/addons/account/demo/account_statement_operations.yml +++ b/addons/account/demo/account_statement_operations.yml @@ -9,7 +9,7 @@ } if account_id: vals['account_id'] = account_id - self._update('account.operation.template', 'account', vals, 'statement_operation_template_1') + self._update(cr, uid, 'account.reconcile.model', 'account', vals, 'account_reconcile_model_1') - !python {model: ir.model.data, id: False} : | account_id = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_expenses')), ('tag_ids', '=', ref('account_tag_operating'))], limit=1).id @@ -21,7 +21,7 @@ } if account_id: vals['account_id'] = account_id - self._update('account.operation.template', 'account', vals, 'statement_operation_template_2') + self._update(cr, uid, 'account.reconcile.model', 'account', vals, 'account_reconcile_model_2') - !python {model: ir.model.data, id: False} : | account_id = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_revenue')), ('tag_ids', '=', ref('account_tag_operating'))], limit=1).id @@ -33,5 +33,5 @@ } if account_id: vals['account_id'] = account_id - self._update('account.operation.template', 'account', vals, 'statement_operation_template_3') + self._update(cr, uid, 'account.reconcile.model', 'account', vals, 'account_reconcile_model_3') - diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 6810c543f38..eb0b26b6963 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -758,8 +758,8 @@ class AccountTax(models.Model): return incl_tax.compute_all(price)['total_excluded'] return price -class AccountOperationTemplate(models.Model): - _name = "account.operation.template" +class AccountReconcileModel(models.Model): + _name = "account.reconcile.model" _description = "Preset to create journal entries during a invoices and payments matching" name = fields.Char(string='Button Label', required=True) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index effca2ce1a4..0bf832c133d 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -335,6 +335,9 @@ class AccountChartTemplate(models.Model): # Generate Fiscal Position , Fiscal Position Accounts and Fiscal Position Taxes from templates self.generate_fiscal_position(taxes_ref, account_ref, company) + # Generate account operation template templates + self.generate_account_reconcile_model(taxes_ref, account_ref, company) + return account_ref, taxes_ref @api.multi @@ -386,6 +389,38 @@ class AccountChartTemplate(models.Model): return acc_template_ref @api.multi + def generate_account_reconcile_model(self, tax_template_ref, acc_template_ref, company): + """ This method for generating accounts from templates. + + :param tax_template_ref: Taxes templates reference for write taxes_id in account_account. + :param acc_template_ref: dictionary with the mappping between the account templates and the real accounts. + :param company_id: company_id selected from wizard.multi.charts.accounts. + :returns: return new_account_reconcile_model for reference purpose. + :rtype: dict + """ + self.ensure_one() + account_reconcile_models = self.env['account.reconcile.model.template'].search([]) + for account_reconcile_model in account_reconcile_models: + vals = { + 'name': account_reconcile_model.name, + 'sequence': account_reconcile_model.sequence, + 'has_second_line': account_reconcile_model.has_second_line, + 'company_id': company.id, + 'account_id': acc_template_ref[account_reconcile_model.account_id.id], + 'label': account_reconcile_model.label, + 'amount_type': account_reconcile_model.amount_type, + 'amount': account_reconcile_model.amount, + 'tax_id': account_reconcile_model.tax_id and tax_template_ref[account_reconcile_model.tax_id.id] or False, + 'second_account_id': account_reconcile_model.second_account_id and acc_template_ref[account_reconcile_model.second_account_id.id] or False, + 'second_label': account_reconcile_model.second_label, + 'second_amount_type': account_reconcile_model.second_amount_type, + 'second_amount': account_reconcile_model.second_amount, + 'second_tax_id': account_reconcile_model.second_tax_id and tax_template_ref[account_reconcile_model.second_tax_id.id] or False, + } + self.create_record_with_xmlid(company, account_reconcile_model, 'account.reconcile.model', vals) + return True + + @api.multi def generate_fiscal_position(self, tax_template_ref, acc_template_ref, company): """ This method generate Fiscal Position, Fiscal Position Accounts and Fiscal Position Taxes from templates. @@ -814,3 +849,27 @@ class AccountBankAccountsWizard(models.TransientModel): currency_id = fields.Many2one('res.currency', string='Account Currency', help="Forces all moves for this account to have this secondary currency.") account_type = fields.Selection([('cash', 'Cash'), ('bank', 'Bank')]) + + +class AccountReconcileModelTemplate(models.Model): + _name = "account.reconcile.model.template" + + name = fields.Char(string='Button Label', required=True) + sequence = fields.Integer(required=True, default=10) + has_second_line = fields.Boolean(string='Add a second line', default=False) + account_id = fields.Many2one('account.account.template', string='Account', ondelete='cascade', domain=[('deprecated', '=', False)]) + label = fields.Char(string='Journal Item Label') + amount_type = fields.Selection([ + ('fixed', 'Fixed'), + ('percentage', 'Percentage of balance') + ], 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.template', string='Tax', ondelete='restrict', domain=[('type_tax_use', '=', 'purchase')]) + second_account_id = fields.Many2one('account.account.template', string='Second Account', ondelete='cascade', domain=[('deprecated', '=', False)]) + second_label = fields.Char(string='Second Journal Item Label') + second_amount_type = fields.Selection([ + ('fixed', 'Fixed'), + ('percentage', 'Percentage of amount') + ], string="Second Amount type",required=True, default='percentage') + second_amount = fields.Float(string='Second 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.template', string='Second Tax', ondelete='restrict', domain=[('type_tax_use', '=', 'purchase')]) diff --git a/addons/account/security/account_security.xml b/addons/account/security/account_security.xml index 6d379560a0b..fdfcb1caaa5 100644 --- a/addons/account/security/account_security.xml +++ b/addons/account/security/account_security.xml @@ -109,9 +109,9 @@ <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field> </record> - <record model="ir.rule" id="account_operation_template_comp_rule"> - <field name="name">Account operation template company rule</field> - <field name="model_id" ref="model_account_operation_template"/> + <record model="ir.rule" id="account_reconcile_model_template_comp_rule"> + <field name="name">Account reconcile model template company rule</field> + <field name="model_id" ref="model_account_reconcile_model"/> <field name="global" eval="True"/> <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field> </record> diff --git a/addons/account/security/ir.model.access.csv b/addons/account/security/ir.model.access.csv index 287a50c8a18..7a1e54c6170 100644 --- a/addons/account/security/ir.model.access.csv +++ b/addons/account/security/ir.model.access.csv @@ -63,7 +63,8 @@ access_account_financial_report,account.financial.report,model_account_financial access_account_financial_report_invoice,account.financial.report invoice,model_account_financial_report,account.group_account_invoice,1,0,0,0 access_account_account_tax,account.account.tag,model_account_account_tag,account.group_account_user,1,0,0,0 access_account_account_tax_user,account.account.tag,model_account_account_tag,account.group_account_invoice,1,0,0,0 -access_account_operation_template,account.operation.template,model_account_operation_template,account.group_account_user,1,1,1,1 +access_account_reconcile_model,account.reconcile.model,model_account_reconcile_model,account.group_account_user,1,1,1,1 +access_account_reconcile_model_template,account.reconcile.model.template,model_account_reconcile_model_template,account.group_account_user,1,1,1,1 access_account_partial_reconcile_group_invoice,account.partial.reconcile.group.invoice,model_account_partial_reconcile,account.group_account_invoice,1,1,1,0 access_account_partial_reconcile,account.partial.reconcile,model_account_partial_reconcile,account.group_account_user,1,1,1,1 access_account_full_reconcile_group_invoice,account.full.reconcile.group.invoice,model_account_full_reconcile,account.group_account_invoice,1,1,1,0 diff --git a/addons/account/static/src/js/account_reconciliation_widgets.js b/addons/account/static/src/js/account_reconciliation_widgets.js index ea63221d763..848b9b5093a 100644 --- a/addons/account/static/src/js/account_reconciliation_widgets.js +++ b/addons/account/static/src/js/account_reconciliation_widgets.js @@ -76,7 +76,7 @@ var abstractReconciliation = Widget.extend(ControlPanelMixin, { this.formatCurrencies; // Method that formats the currency ; loaded from the server this.model_res_users = new Model("res.users"); this.model_tax = new Model("account.tax"); - this.model_presets = new Model("account.operation.template"); + this.model_presets = new Model("account.reconcile.model"); this.max_move_lines_displayed = 5; // Number of reconciliations loaded initially and by clicking 'show more' this.num_reconciliations_fetched_in_batch = 10; @@ -277,7 +277,7 @@ var abstractReconciliation = Widget.extend(ControlPanelMixin, { presetConfigCreateClickHandler: function(e) { e.preventDefault(); var self = this; - return self.rpc("/web/action/load", {action_id: "account.action_account_operation_template"}).then(function(result) { + return self.rpc("/web/action/load", {action_id: "account.action_account_reconcile_model"}).then(function(result) { result.views = [[false, "form"], [false, "list"]]; return self.do_action(result); }); @@ -286,7 +286,7 @@ var abstractReconciliation = Widget.extend(ControlPanelMixin, { presetConfigEditClickHandler: function(e) { e.preventDefault(); var self = this; - return self.rpc("/web/action/load", {action_id: "account.action_account_operation_template"}).then(function(result) { + return self.rpc("/web/action/load", {action_id: "account.action_account_reconcile_model"}).then(function(result) { result.views = [[false, "list"], [false, "form"]]; return self.do_action(result); }); diff --git a/addons/account/views/account_journal_dashboard_view.xml b/addons/account/views/account_journal_dashboard_view.xml index 8ff924a63aa..61318f7323d 100644 --- a/addons/account/views/account_journal_dashboard_view.xml +++ b/addons/account/views/account_journal_dashboard_view.xml @@ -99,7 +99,7 @@ <span t-if="dashboard.number_to_reconcile == 0" class="text-muted">Nothing to Reconcile</span> </div> <div> - <a type="object" name="open_action_with_context" context="{'action_name': 'action_account_operation_template', 'use_domain': True}" groups="account.group_account_manager">Reconciliation Models</a> + <a type="object" name="open_action_with_context" context="{'action_name': 'action_account_reconcile_model', 'use_domain': True}" groups="account.group_account_manager">Reconciliation Models</a> </div> </div> </div> diff --git a/addons/account/views/account_view.xml b/addons/account/views/account_view.xml index 02ddfdacd5b..bde3c8071e0 100644 --- a/addons/account/views/account_view.xml +++ b/addons/account/views/account_view.xml @@ -753,9 +753,9 @@ <field name="tag">manual_reconciliation_view</field> </record> - <record id="view_account_operation_template_form" model="ir.ui.view"> - <field name="name">account.operation.template.form</field> - <field name="model">account.operation.template</field> + <record id="view_account_reconcile_model_form" model="ir.ui.view"> + <field name="name">account.reconcile.model.form</field> + <field name="model">account.reconcile.model</field> <field name="arch" type="xml"> <form string="Operation Templates"> <sheet> @@ -806,9 +806,9 @@ </form> </field> </record> - <record id="view_account_operation_template_tree" model="ir.ui.view"> - <field name="name">account.operation.template.tree</field> - <field name="model">account.operation.template</field> + <record id="view_account_reconcile_model_tree" model="ir.ui.view"> + <field name="name">account.reconcile.model.tree</field> + <field name="model">account.reconcile.model</field> <field name="arch" type="xml"> <tree string="Bank Reconciliation Move Presets"> <field name="sequence" widget="handle" /> @@ -819,9 +819,9 @@ </tree> </field> </record> - <record id="view_account_operation_template_search" model="ir.ui.view"> - <field name="name">account.operation.template.search</field> - <field name="model">account.operation.template</field> + <record id="view_account_reconcile_model_search" model="ir.ui.view"> + <field name="name">account.reconcile.model.search</field> + <field name="model">account.reconcile.model</field> <field name="arch" type="xml"> <search string="Bank Reconciliation Move preset"> <filter string="With tax" domain="[('tax_id','!=',False)]"/> @@ -830,12 +830,12 @@ </search> </field> </record> - <record id="action_account_operation_template" model="ir.actions.act_window"> + <record id="action_account_reconcile_model" model="ir.actions.act_window"> <field name="name">Reconciliation Models</field> - <field name="res_model">account.operation.template</field> + <field name="res_model">account.reconcile.model</field> <field name="view_type">form</field> <field name="view_mode">tree,form</field> - <field name="search_view_id" ref="view_account_operation_template_search"/> + <field name="search_view_id" ref="view_account_reconcile_model_search"/> <field name="help" type="html"> <p class="oe_view_nocontent_create"> Click to create a reconciliation model. diff --git a/addons/l10n_be/__openerp__.py b/addons/l10n_be/__openerp__.py index 0e41d9cef1b..b19362519ae 100644 --- a/addons/l10n_be/__openerp__.py +++ b/addons/l10n_be/__openerp__.py @@ -48,8 +48,9 @@ Wizards provided by this module: 'data/l10n_be_sequence_data.xml', 'data/fiscal_templates_data.xml', 'data/account_fiscal_position_tax_template_data.xml', + 'data/account_reconcile_model_template.xml', 'data/account_chart_template_data.yml', - 'data/menuitem_data.xml' + 'data/menuitem_data.xml', ], 'demo': [ 'demo/l10n_be_demo.yml', diff --git a/addons/l10n_be/data/account_pcmn_belgium_data.xml b/addons/l10n_be/data/account_pcmn_belgium_data.xml index 27839c6f65d..1f47f09cc08 100644 --- a/addons/l10n_be/data/account_pcmn_belgium_data.xml +++ b/addons/l10n_be/data/account_pcmn_belgium_data.xml @@ -908,6 +908,13 @@ <field name="chart_template_id" ref="l10nbe_chart_template"/> <field name="tag_ids" eval="[(6,0,[ref('account.account_tag_operating')])]"/> </record> + <record id="a653" model="account.account.template"> + <field name="code">653</field> + <field name="name">Escomptes clients</field> + <field name="user_type_id" ref="account.data_account_type_expenses" /> + <field name="chart_template_id" ref="l10nbe_chart_template"/> + <field name="tag_ids" eval="[(6,0,[ref('account.account_tag_financing')])]"/> + </record> <record id="a654" model="account.account.template"> <field name="name">Différences de change</field> <field name="code">654</field> diff --git a/addons/l10n_be/data/account_reconcile_model_template.xml b/addons/l10n_be/data/account_reconcile_model_template.xml new file mode 100644 index 00000000000..64b541fec1f --- /dev/null +++ b/addons/l10n_be/data/account_reconcile_model_template.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<odoo> + <record id="escompte_template" model="account.reconcile.model.template"> + <field name="name">Escompte</field> + <field name="account_id" ref="a653"/> + <field name="amount_type">percentage</field> + <field name="amount">100</field> + <field name="label">Escompte accordé</field> + </record> + <record id="frais_bancaires_htva_template" model="account.reconcile.model.template"> + <field name="name">Frais bancaires HTVA</field> + <field name="account_id" ref="a656" /> + <field name="amount_type">percentage</field> + <field name="amount">100</field> + <field name="label">Frais bancaires HTVA</field> + </record> + <record id="frais_bancaires_tva21_template" model="account.reconcile.model.template"> + <field name="name">Frais bancaires TVA21</field> + <field name="account_id" ref="a656"/> + <field name="amount_type">percentage</field> + <field name="tax_id" ref="attn_TVA-21-inclus-dans-prix"/> + <field name="amount">100</field> + <field name="label">Frais bancaires TVA21</field> + </record> + <record id="virements_internes_template" model="account.reconcile.model.template"> + <field name="name">Virements internes</field> + <field name="account_id" ref="trans"/> + <field name="amount_type">percentage</field> + <field name="amount">100</field> + <field name="label">Virements internes</field> + </record> +</odoo> diff --git a/addons/l10n_be/data/account_tax_template_data.xml b/addons/l10n_be/data/account_tax_template_data.xml index 48f91610f53..d52c55a9bef 100644 --- a/addons/l10n_be/data/account_tax_template_data.xml +++ b/addons/l10n_be/data/account_tax_template_data.xml @@ -344,6 +344,19 @@ <field name="chart_template_id" ref="l10nbe_chart_template"/> <field name="tag_ids" eval="[(6,0,[ref('tax_tag_81'), ref('tax_tag_85')])]"/> </record> + <record id="attn_TVA-21-inclus-dans-prix" model="account.tax.template"> + <field name="sequence">12</field> + <field name="description">21% Services - TTC</field> + <field name="name">21% TVA</field> + <field name="refund_account_id" ref="a411059"/> + <field name="account_id" ref="a411059"/> + <field name="price_include" eval="1"/> + <field name="amount">21</field> + <field name="amount_type">percent</field> + <field name="type_tax_use">none</field> + <field name="chart_template_id" ref="l10nbe_chart_template"/> + <field name="tag_ids" eval="[(6,0,[ref('tax_tag_82'), ref('tax_tag_85'), ref('tax_tag_63'), ref('tax_tag_59')])]"/> + </record> <record id="attn_VAT-IN-V82-21-S" model="account.tax.template"> <field name="sequence">210</field> <field name="description">21%</field> |
