From 29dd6ed8f06ff89d2864cab6d07ef0811d425822 Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Tue, 19 Jul 2016 10:18:25 +0200 Subject: [PATCH 01/12] [MOV] account_check_printing: reorganize files according to guidelines --- addons/account_check_printing/__init__.py | 5 +---- addons/account_check_printing/__openerp__.py | 12 ++++++------ ..._printing.xml => account_check_printing_data.xml} | 0 addons/account_check_printing/models/__init__.py | 6 ++++++ .../{ => models}/account_journal.py | 0 .../{ => models}/account_journal_dashboard.py | 0 .../{ => models}/account_payment.py | 0 ..._view.xml => account_journal_dashboard_views.xml} | 0 ...nt_journal_view.xml => account_journal_views.xml} | 0 ...nt_payment_view.xml => account_payment_views.xml} | 0 addons/account_check_printing/wizard/__init__.py | 2 +- ...umbered_checks.py => print_prenumbered_checks.py} | 0 ...checks.xml => print_prenumbered_checks_views.xml} | 0 13 files changed, 14 insertions(+), 11 deletions(-) rename addons/account_check_printing/data/{check_printing.xml => account_check_printing_data.xml} (100%) create mode 100644 addons/account_check_printing/models/__init__.py rename addons/account_check_printing/{ => models}/account_journal.py (100%) rename addons/account_check_printing/{ => models}/account_journal_dashboard.py (100%) rename addons/account_check_printing/{ => models}/account_payment.py (100%) rename addons/account_check_printing/views/{account_journal_dashboard_view.xml => account_journal_dashboard_views.xml} (100%) rename addons/account_check_printing/views/{account_journal_view.xml => account_journal_views.xml} (100%) rename addons/account_check_printing/views/{account_payment_view.xml => account_payment_views.xml} (100%) rename addons/account_check_printing/wizard/{print_pre_numbered_checks.py => print_prenumbered_checks.py} (100%) rename addons/account_check_printing/wizard/{print_pre_numbered_checks.xml => print_prenumbered_checks_views.xml} (100%) diff --git a/addons/account_check_printing/__init__.py b/addons/account_check_printing/__init__.py index 86524733c84..e2b122e1a08 100644 --- a/addons/account_check_printing/__init__.py +++ b/addons/account_check_printing/__init__.py @@ -1,7 +1,4 @@ # -*- coding: utf-8 -*- -import account_journal -import account_journal_dashboard -import account_payment - +import models import wizard diff --git a/addons/account_check_printing/__openerp__.py b/addons/account_check_printing/__openerp__.py index c3d380b4fdd..93ce80a6ea7 100644 --- a/addons/account_check_printing/__openerp__.py +++ b/addons/account_check_printing/__openerp__.py @@ -10,13 +10,13 @@ It must be used as a dependency for modules that provide country-specific check The check settings are located in the accounting journals configuration page. """, 'website': 'https://www.odoo.com/page/accounting', - 'depends' : ['account'], + 'depends': ['account'], 'data': [ - 'data/check_printing.xml', - 'views/account_journal_dashboard_view.xml', - 'views/account_journal_view.xml', - 'views/account_payment_view.xml', - 'wizard/print_pre_numbered_checks.xml' + 'data/account_check_printing_data.xml', + 'views/account_journal_dashboard_views.xml', + 'views/account_journal_views.xml', + 'views/account_payment_views.xml', + 'wizard/print_prenumbered_checks_views.xml' ], 'installable': True, 'auto_install': False, diff --git a/addons/account_check_printing/data/check_printing.xml b/addons/account_check_printing/data/account_check_printing_data.xml similarity index 100% rename from addons/account_check_printing/data/check_printing.xml rename to addons/account_check_printing/data/account_check_printing_data.xml diff --git a/addons/account_check_printing/models/__init__.py b/addons/account_check_printing/models/__init__.py new file mode 100644 index 00000000000..9c4ae23a06d --- /dev/null +++ b/addons/account_check_printing/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import account_journal +import account_journal_dashboard +import account_payment diff --git a/addons/account_check_printing/account_journal.py b/addons/account_check_printing/models/account_journal.py similarity index 100% rename from addons/account_check_printing/account_journal.py rename to addons/account_check_printing/models/account_journal.py diff --git a/addons/account_check_printing/account_journal_dashboard.py b/addons/account_check_printing/models/account_journal_dashboard.py similarity index 100% rename from addons/account_check_printing/account_journal_dashboard.py rename to addons/account_check_printing/models/account_journal_dashboard.py diff --git a/addons/account_check_printing/account_payment.py b/addons/account_check_printing/models/account_payment.py similarity index 100% rename from addons/account_check_printing/account_payment.py rename to addons/account_check_printing/models/account_payment.py diff --git a/addons/account_check_printing/views/account_journal_dashboard_view.xml b/addons/account_check_printing/views/account_journal_dashboard_views.xml similarity index 100% rename from addons/account_check_printing/views/account_journal_dashboard_view.xml rename to addons/account_check_printing/views/account_journal_dashboard_views.xml diff --git a/addons/account_check_printing/views/account_journal_view.xml b/addons/account_check_printing/views/account_journal_views.xml similarity index 100% rename from addons/account_check_printing/views/account_journal_view.xml rename to addons/account_check_printing/views/account_journal_views.xml diff --git a/addons/account_check_printing/views/account_payment_view.xml b/addons/account_check_printing/views/account_payment_views.xml similarity index 100% rename from addons/account_check_printing/views/account_payment_view.xml rename to addons/account_check_printing/views/account_payment_views.xml diff --git a/addons/account_check_printing/wizard/__init__.py b/addons/account_check_printing/wizard/__init__.py index 0d305b91dc3..118be64634d 100644 --- a/addons/account_check_printing/wizard/__init__.py +++ b/addons/account_check_printing/wizard/__init__.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -import print_pre_numbered_checks +import print_prenumbered_checks diff --git a/addons/account_check_printing/wizard/print_pre_numbered_checks.py b/addons/account_check_printing/wizard/print_prenumbered_checks.py similarity index 100% rename from addons/account_check_printing/wizard/print_pre_numbered_checks.py rename to addons/account_check_printing/wizard/print_prenumbered_checks.py diff --git a/addons/account_check_printing/wizard/print_pre_numbered_checks.xml b/addons/account_check_printing/wizard/print_prenumbered_checks_views.xml similarity index 100% rename from addons/account_check_printing/wizard/print_pre_numbered_checks.xml rename to addons/account_check_printing/wizard/print_prenumbered_checks_views.xml From dcab4afda48b54b16a0f1ac36b26b66177ca3c4a Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Tue, 19 Jul 2016 10:20:41 +0200 Subject: [PATCH 02/12] [MOV] account_check_printing: merge account_journal dashboard methods and views into account_journal --- addons/account_check_printing/__openerp__.py | 1 - .../account_check_printing/models/__init__.py | 1 - .../models/account_journal.py | 29 +++++++++++++++ .../models/account_journal_dashboard.py | 35 ------------------- .../views/account_journal_dashboard_views.xml | 24 ------------- .../views/account_journal_views.xml | 21 +++++++++++ 6 files changed, 50 insertions(+), 61 deletions(-) delete mode 100644 addons/account_check_printing/models/account_journal_dashboard.py delete mode 100644 addons/account_check_printing/views/account_journal_dashboard_views.xml diff --git a/addons/account_check_printing/__openerp__.py b/addons/account_check_printing/__openerp__.py index 93ce80a6ea7..c65c51d7c38 100644 --- a/addons/account_check_printing/__openerp__.py +++ b/addons/account_check_printing/__openerp__.py @@ -13,7 +13,6 @@ The check settings are located in the accounting journals configuration page. 'depends': ['account'], 'data': [ 'data/account_check_printing_data.xml', - 'views/account_journal_dashboard_views.xml', 'views/account_journal_views.xml', 'views/account_payment_views.xml', 'wizard/print_prenumbered_checks_views.xml' diff --git a/addons/account_check_printing/models/__init__.py b/addons/account_check_printing/models/__init__.py index 9c4ae23a06d..b07a9ea0961 100644 --- a/addons/account_check_printing/models/__init__.py +++ b/addons/account_check_printing/models/__init__.py @@ -2,5 +2,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. import account_journal -import account_journal_dashboard import account_payment diff --git a/addons/account_check_printing/models/account_journal.py b/addons/account_check_printing/models/account_journal.py index 7470787d322..7764eb288eb 100644 --- a/addons/account_check_printing/models/account_journal.py +++ b/addons/account_check_printing/models/account_journal.py @@ -76,3 +76,32 @@ class AccountJournal(models.Model): bank_journal.write({ 'outbound_payment_method_ids': [(4, check_printing.id, None)], }) + + @api.multi + def get_journal_dashboard_datas(self): + domain_checks_to_print = [ + ('journal_id', '=', self.id), + ('payment_method_id.code', '=', 'check_printing'), + ('state', '=', 'posted') + ] + return dict( + super(AccountJournal, self).get_journal_dashboard_datas(), + num_checks_to_print=len(self.env['account.payment'].search(domain_checks_to_print)) + ) + + @api.multi + def action_checks_to_print(self): + return { + 'name': _('Checks to Print'), + 'type': 'ir.actions.act_window', + 'view_mode': 'list,form,graph', + 'res_model': 'account.payment', + 'context': dict( + self.env.context, + search_default_checks_to_send=1, + journal_id=self.id, + default_journal_id=self.id, + default_payment_type='outbound', + default_payment_method_id=self.env.ref('account_check_printing.account_payment_method_check').id, + ), + } diff --git a/addons/account_check_printing/models/account_journal_dashboard.py b/addons/account_check_printing/models/account_journal_dashboard.py deleted file mode 100644 index 3b1fc1b93cc..00000000000 --- a/addons/account_check_printing/models/account_journal_dashboard.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- - -from openerp import models, api, _ - -class account_journal(models.Model): - _inherit = "account.journal" - - @api.multi - def get_journal_dashboard_datas(self): - domain_checks_to_print = [ - ('journal_id', '=', self.id), - ('payment_method_id.code', '=', 'check_printing'), - ('state','=','posted') - ] - return dict( - super(account_journal, self).get_journal_dashboard_datas(), - num_checks_to_print=len(self.env['account.payment'].search(domain_checks_to_print)) - ) - - @api.multi - def action_checks_to_print(self): - return { - 'name': _('Checks to Print'), - 'type': 'ir.actions.act_window', - 'view_mode': 'list,form,graph', - 'res_model': 'account.payment', - 'context': dict( - self.env.context, - search_default_checks_to_send=1, - journal_id=self.id, - default_journal_id=self.id, - default_payment_type='outbound', - default_payment_method_id=self.env.ref('account_check_printing.account_payment_method_check').id, - ), - } diff --git a/addons/account_check_printing/views/account_journal_dashboard_views.xml b/addons/account_check_printing/views/account_journal_dashboard_views.xml deleted file mode 100644 index 8ce220b7eee..00000000000 --- a/addons/account_check_printing/views/account_journal_dashboard_views.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - account.journal.dashboard.kanban.inherited - account.journal - - - - - - - - - diff --git a/addons/account_check_printing/views/account_journal_views.xml b/addons/account_check_printing/views/account_journal_views.xml index 9f180bb099b..8aaed6a59b4 100644 --- a/addons/account_check_printing/views/account_journal_views.xml +++ b/addons/account_check_printing/views/account_journal_views.xml @@ -1,6 +1,27 @@ + + account.journal.dashboard.kanban.inherited + account.journal + + + + + + + + account.journal.form.inherited account.journal From 2163d2b7f7fc8390b70dbc94c2440df8f866fcc8 Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Tue, 19 Jul 2016 10:28:52 +0200 Subject: [PATCH 03/12] [MIG] account_check_printing: replace openerp tags, clean imports and rename classes --- addons/account_check_printing/__init__.py | 1 + addons/account_check_printing/__openerp__.py | 2 ++ .../data/account_check_printing_data.xml | 4 +-- .../models/account_journal.py | 5 +-- .../models/account_payment.py | 34 ++++++++++--------- .../views/account_journal_views.xml | 6 ++-- .../views/account_payment_views.xml | 6 ++-- .../account_check_printing/wizard/__init__.py | 1 + .../wizard/print_prenumbered_checks.py | 6 ++-- .../wizard/print_prenumbered_checks_views.xml | 6 ++-- 10 files changed, 37 insertions(+), 34 deletions(-) diff --git a/addons/account_check_printing/__init__.py b/addons/account_check_printing/__init__.py index e2b122e1a08..11529f98733 100644 --- a/addons/account_check_printing/__init__.py +++ b/addons/account_check_printing/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. import models import wizard diff --git a/addons/account_check_printing/__openerp__.py b/addons/account_check_printing/__openerp__.py index c65c51d7c38..345f20c27a3 100644 --- a/addons/account_check_printing/__openerp__.py +++ b/addons/account_check_printing/__openerp__.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + { 'name': 'Check Printing Base', 'version': '1.0', diff --git a/addons/account_check_printing/data/account_check_printing_data.xml b/addons/account_check_printing/data/account_check_printing_data.xml index 48dbad8c15d..4fd632173af 100644 --- a/addons/account_check_printing/data/account_check_printing_data.xml +++ b/addons/account_check_printing/data/account_check_printing_data.xml @@ -1,5 +1,5 @@ - + @@ -30,4 +30,4 @@ - + diff --git a/addons/account_check_printing/models/account_journal.py b/addons/account_check_printing/models/account_journal.py index 7764eb288eb..6bdc23269af 100644 --- a/addons/account_check_printing/models/account_journal.py +++ b/addons/account_check_printing/models/account_journal.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. -from openerp import models, fields, api, _ -from openerp.exceptions import ValidationError +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError class AccountJournal(models.Model): _inherit = "account.journal" diff --git a/addons/account_check_printing/models/account_payment.py b/addons/account_check_printing/models/account_payment.py index 68850f7c206..30019379029 100644 --- a/addons/account_check_printing/models/account_payment.py +++ b/addons/account_check_printing/models/account_payment.py @@ -1,12 +1,14 @@ # -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. import math -from openerp import models, fields, api, _ -from openerp.tools import amount_to_text_en, float_round -from openerp.exceptions import UserError, ValidationError +from odoo import models, fields, api, _ +from odoo.tools import amount_to_text_en, float_round +from odoo.exceptions import UserError, ValidationError -class account_register_payments(models.TransientModel): + +class AccountRegisterPayments(models.TransientModel): _inherit = "account.register.payments" check_amount_in_words = fields.Char(string="Amount in Words") @@ -18,15 +20,15 @@ class account_register_payments(models.TransientModel): @api.onchange('journal_id') def _onchange_journal_id(self): - if hasattr(super(account_register_payments, self), '_onchange_journal_id'): - super(account_register_payments, self)._onchange_journal_id() + if hasattr(super(AccountRegisterPayments, self), '_onchange_journal_id'): + super(AccountRegisterPayments, self)._onchange_journal_id() if self.journal_id.check_manual_sequencing: self.check_number = self.journal_id.check_sequence_id.number_next_actual @api.onchange('amount') def _onchange_amount(self): - if hasattr(super(account_register_payments, self), '_onchange_amount'): - super(account_register_payments, self)._onchange_amount() + if hasattr(super(AccountRegisterPayments, self), '_onchange_amount'): + super(AccountRegisterPayments, self)._onchange_amount() # TODO: merge, refactor and complete the amount_to_text and amount_to_text_en classes check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(self.amount), lang='en', currency='') check_amount_in_words = check_amount_in_words.replace(' and Zero Cent', '') # Ugh @@ -36,7 +38,7 @@ class account_register_payments(models.TransientModel): self.check_amount_in_words = check_amount_in_words def get_payment_vals(self): - res = super(account_register_payments, self).get_payment_vals() + res = super(AccountRegisterPayments, self).get_payment_vals() if self.payment_method_id == self.env.ref('account_check_printing.account_payment_method_check'): res.update({ 'check_amount_in_words': self.check_amount_in_words, @@ -45,7 +47,7 @@ class account_register_payments(models.TransientModel): return res -class account_payment(models.Model): +class AccountPayment(models.Model): _inherit = "account.payment" check_amount_in_words = fields.Char(string="Amount in Words") @@ -56,15 +58,15 @@ class account_payment(models.Model): @api.onchange('journal_id') def _onchange_journal_id(self): - if hasattr(super(account_payment, self), '_onchange_journal_id'): - super(account_payment, self)._onchange_journal_id() + if hasattr(super(AccountPayment, self), '_onchange_journal_id'): + super(AccountPayment, self)._onchange_journal_id() if self.journal_id.check_manual_sequencing: self.check_number = self.journal_id.check_sequence_id.number_next_actual @api.onchange('amount') def _onchange_amount(self): - if hasattr(super(account_payment, self), '_onchange_amount'): - super(account_payment, self)._onchange_amount() + if hasattr(super(AccountPayment, self), '_onchange_amount'): + super(AccountPayment, self)._onchange_amount() check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(self.amount), lang='en', currency='') check_amount_in_words = check_amount_in_words.replace(' and Zero Cent', '') # Ugh decimals = self.amount % 1 @@ -73,7 +75,7 @@ class account_payment(models.Model): self.check_amount_in_words = check_amount_in_words def _check_communication(self, payment_method_id, communication): - super(account_payment, self)._check_communication(payment_method_id, communication) + super(AccountPayment, self)._check_communication(payment_method_id, communication) if payment_method_id == self.env.ref('account_check_printing.account_payment_method_check').id: if not communication: return @@ -86,7 +88,7 @@ class account_payment(models.Model): and vals.get('check_manual_sequencing'): sequence = self.env['account.journal'].browse(vals['journal_id']).check_sequence_id vals.update({'check_number': sequence.next_by_id()}) - return super(account_payment, self.sudo()).create(vals) + return super(AccountPayment, self.sudo()).create(vals) @api.multi def print_checks(self): diff --git a/addons/account_check_printing/views/account_journal_views.xml b/addons/account_check_printing/views/account_journal_views.xml index 8aaed6a59b4..11bcb277b5a 100644 --- a/addons/account_check_printing/views/account_journal_views.xml +++ b/addons/account_check_printing/views/account_journal_views.xml @@ -1,6 +1,5 @@ - - + account.journal.dashboard.kanban.inherited account.journal @@ -37,5 +36,4 @@ - - + diff --git a/addons/account_check_printing/views/account_payment_views.xml b/addons/account_check_printing/views/account_payment_views.xml index 33fd221cda5..f54a93ea0b2 100644 --- a/addons/account_check_printing/views/account_payment_views.xml +++ b/addons/account_check_printing/views/account_payment_views.xml @@ -1,6 +1,5 @@ - - + account.payment.form.inherited account.payment @@ -61,5 +60,4 @@ - - + diff --git a/addons/account_check_printing/wizard/__init__.py b/addons/account_check_printing/wizard/__init__.py index 118be64634d..cfb239ad5c1 100644 --- a/addons/account_check_printing/wizard/__init__.py +++ b/addons/account_check_printing/wizard/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. import print_prenumbered_checks diff --git a/addons/account_check_printing/wizard/print_prenumbered_checks.py b/addons/account_check_printing/wizard/print_prenumbered_checks.py index 4bf1d912bda..79af6f69dd0 100644 --- a/addons/account_check_printing/wizard/print_prenumbered_checks.py +++ b/addons/account_check_printing/wizard/print_prenumbered_checks.py @@ -1,8 +1,10 @@ # -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. -from openerp import api, fields, models +from odoo import api, fields, models -class print_pre_numbered_checks(models.TransientModel): + +class PrintPreNumberedChecks(models.TransientModel): _name = 'print.prenumbered.checks' _description = 'Print Pre-numbered Checks' diff --git a/addons/account_check_printing/wizard/print_prenumbered_checks_views.xml b/addons/account_check_printing/wizard/print_prenumbered_checks_views.xml index 482462a5017..9b136b3a8dc 100644 --- a/addons/account_check_printing/wizard/print_prenumbered_checks_views.xml +++ b/addons/account_check_printing/wizard/print_prenumbered_checks_views.xml @@ -1,6 +1,5 @@ - - + Print Pre-numbered Checks @@ -21,5 +20,4 @@ - - + From b113f1cb588a814354c085b0ace164632f18dd8c Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Tue, 19 Jul 2016 10:32:45 +0200 Subject: [PATCH 04/12] [MOV] account_tax_cash_basis: reorganize files according to guidelines --- addons/account_tax_cash_basis/__init__.py | 2 +- addons/account_tax_cash_basis/models/__init__.py | 4 ++++ addons/account_tax_cash_basis/{ => models}/tax_cash_basis.py | 0 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 addons/account_tax_cash_basis/models/__init__.py rename addons/account_tax_cash_basis/{ => models}/tax_cash_basis.py (100%) diff --git a/addons/account_tax_cash_basis/__init__.py b/addons/account_tax_cash_basis/__init__.py index e6b78dead08..81fc81d29c9 100644 --- a/addons/account_tax_cash_basis/__init__.py +++ b/addons/account_tax_cash_basis/__init__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -import tax_cash_basis +import models diff --git a/addons/account_tax_cash_basis/models/__init__.py b/addons/account_tax_cash_basis/models/__init__.py new file mode 100644 index 00000000000..e6b78dead08 --- /dev/null +++ b/addons/account_tax_cash_basis/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import tax_cash_basis diff --git a/addons/account_tax_cash_basis/tax_cash_basis.py b/addons/account_tax_cash_basis/models/tax_cash_basis.py similarity index 100% rename from addons/account_tax_cash_basis/tax_cash_basis.py rename to addons/account_tax_cash_basis/models/tax_cash_basis.py From f28f35fa1544c5d5ce86b98eb936d7eba3d663f8 Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Tue, 19 Jul 2016 10:51:23 +0200 Subject: [PATCH 05/12] [MOV] account_tax_cash_basis: split account models and views into their own files --- addons/account_tax_cash_basis/__openerp__.py | 3 +- .../account_tax_cash_basis/models/__init__.py | 6 +- .../models/account_config_settings.py | 13 ++++ .../models/account_move.py | 14 +++++ ..._basis.py => account_partial_reconcile.py} | 59 +++++-------------- .../models/account_tax.py | 18 ++++++ .../models/res_company.py | 10 ++++ .../views/account_config_setting_views.xml | 16 +++++ ...h_basis_view.xml => account_tax_views.xml} | 14 ----- 9 files changed, 94 insertions(+), 59 deletions(-) create mode 100644 addons/account_tax_cash_basis/models/account_config_settings.py create mode 100644 addons/account_tax_cash_basis/models/account_move.py rename addons/account_tax_cash_basis/models/{tax_cash_basis.py => account_partial_reconcile.py} (61%) create mode 100644 addons/account_tax_cash_basis/models/account_tax.py create mode 100644 addons/account_tax_cash_basis/models/res_company.py create mode 100644 addons/account_tax_cash_basis/views/account_config_setting_views.xml rename addons/account_tax_cash_basis/views/{tax_cash_basis_view.xml => account_tax_views.xml} (52%) diff --git a/addons/account_tax_cash_basis/__openerp__.py b/addons/account_tax_cash_basis/__openerp__.py index c6de2ca37a6..92d8644e561 100644 --- a/addons/account_tax_cash_basis/__openerp__.py +++ b/addons/account_tax_cash_basis/__openerp__.py @@ -13,7 +13,8 @@ 'website': 'https://www.odoo.com/page/accounting', 'depends' : ['account'], 'data': [ - 'views/tax_cash_basis_view.xml', + 'views/account_tax_views.xml', + 'views/account_config_setting_views.xml', ], 'installable': True, 'auto_install': False, diff --git a/addons/account_tax_cash_basis/models/__init__.py b/addons/account_tax_cash_basis/models/__init__.py index e6b78dead08..79092458d54 100644 --- a/addons/account_tax_cash_basis/models/__init__.py +++ b/addons/account_tax_cash_basis/models/__init__.py @@ -1,4 +1,8 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -import tax_cash_basis +import account_config_settings +import account_move +import account_partial_reconcile +import account_tax +import res_company diff --git a/addons/account_tax_cash_basis/models/account_config_settings.py b/addons/account_tax_cash_basis/models/account_config_settings.py new file mode 100644 index 00000000000..5c2f71ecfff --- /dev/null +++ b/addons/account_tax_cash_basis/models/account_config_settings.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models, fields + + +class AccountConfigSettings(models.TransientModel): + _inherit = 'account.config.settings' + + tax_cash_basis_journal_id = fields.Many2one( + 'account.journal', + related='company_id.tax_cash_basis_journal_id', + string="Tax Cash Basis Journal",) diff --git a/addons/account_tax_cash_basis/models/account_move.py b/addons/account_tax_cash_basis/models/account_move.py new file mode 100644 index 00000000000..1fac8221343 --- /dev/null +++ b/addons/account_tax_cash_basis/models/account_move.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models, fields + + +class AccountMoveCashBasis(models.Model): + _inherit = 'account.move' + + tax_cash_basis_rec_id = fields.Many2one( + 'account.partial.reconcile', + string='Tax Cash Basis Entry of', + help="Technical field used to keep track of the tax cash basis reconciliation." + "This is needed when cancelling the source: it will post the inverse journal entry to cancel that part too.") diff --git a/addons/account_tax_cash_basis/models/tax_cash_basis.py b/addons/account_tax_cash_basis/models/account_partial_reconcile.py similarity index 61% rename from addons/account_tax_cash_basis/models/tax_cash_basis.py rename to addons/account_tax_cash_basis/models/account_partial_reconcile.py index 8f45ab3e3a9..bb6bff7f53c 100644 --- a/addons/account_tax_cash_basis/models/tax_cash_basis.py +++ b/addons/account_tax_cash_basis/models/account_partial_reconcile.py @@ -1,64 +1,37 @@ # -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. -from openerp import models, fields, api, _ -from openerp.exceptions import UserError - -class AccountTaxCashBasis(models.Model): - _inherit = 'account.tax' - - use_cash_basis = fields.Boolean('Use Cash Basis', help='Select this if the tax should use cash basis, which will \ - create an entry for this tax on a given account during reconciliation') - cash_basis_account = fields.Many2one('account.account', string='Tax Received Account', domain=[('deprecated', '=', False)], help='Account use when \ - creating entry for tax cash basis') - - -class AccountMoveCashBasis(models.Model): - _inherit = 'account.move' - - tax_cash_basis_rec_id = fields.Many2one('account.partial.reconcile', string='Tax Cash Basis Entry of', help="Technical field used to keep track of the tax cash basis reconciliation. This is needed when cancelling the source: it will post the inverse journal entry to cancel that part too.") - - -class AccountConfigSettings(models.TransientModel): - _inherit = 'account.config.settings' - - tax_cash_basis_journal_id = fields.Many2one('account.journal', - related='company_id.tax_cash_basis_journal_id', - string="Tax Cash Basis Journal",) - - -class ResCompany(models.Model): - _inherit = 'res.company' - - tax_cash_basis_journal_id = fields.Many2one('account.journal', string="Tax Cash Basis Journal") +from odoo import api, models, _ +from odoo.exceptions import UserError class AccountPartialReconcileCashBasis(models.Model): _inherit = 'account.partial.reconcile' def create_tax_cash_basis_entry(self, value_before_reconciliation): - #Search in account_move if we have any taxes account move lines + # Search in account_move if we have any taxes account move lines tax_group = {} total_by_cash_basis_account = {} for move in (self.debit_move_id.move_id, self.credit_move_id.move_id): for line in move.line_ids: if line.tax_line_id and line.tax_line_id.use_cash_basis: - #amount to write is the current cash_basis amount minus the one before the reconciliation + # amount to write is the current cash_basis amount minus the one before the reconciliation matched_percentage = value_before_reconciliation[move.id] amount = (line.credit_cash_basis - line.debit_cash_basis) - (line.credit - line.debit) * matched_percentage - #group by line account + # group by line account acc = line.account_id.id if tax_group.get(acc, False): tax_group[acc] += amount else: tax_group[acc] = amount - #Group by cash basis account + # Group by cash basis account acc = line.tax_line_id.cash_basis_account.id if total_by_cash_basis_account.get(acc, False): total_by_cash_basis_account[acc] += amount else: total_by_cash_basis_account[acc] = amount line_to_create = [] - for k,v in tax_group.items(): + for k, v in tax_group.items(): line_to_create.append((0, 0, { 'name': '/', 'debit': v if v > 0 else 0.0, @@ -66,8 +39,8 @@ class AccountPartialReconcileCashBasis(models.Model): 'account_id': k, })) - #Create counterpart vals - for k,v in total_by_cash_basis_account.items(): + # Create counterpart vals + for k, v in total_by_cash_basis_account.items(): line_to_create.append((0, 0, { 'name': '/', 'debit': abs(v) if v < 0 else 0.0, @@ -75,9 +48,9 @@ class AccountPartialReconcileCashBasis(models.Model): 'account_id': k, })) - #Create move + # Create move if len(line_to_create) > 0: - #Check if company_journal for cash basis is set if not, raise exception + # Check if company_journal for cash basis is set if not, raise exception if not self.company_id.tax_cash_basis_journal_id: raise UserError(_('There is no tax cash basis journal defined ' \ 'for this company: "%s" \nConfigure it in Accounting/Configuration/Settings') % \ @@ -86,7 +59,7 @@ class AccountPartialReconcileCashBasis(models.Model): 'journal_id': self.company_id.tax_cash_basis_journal_id.id, 'line_ids': line_to_create, 'tax_cash_basis_rec_id': self.id}) - #post move + # post move move.post() @api.model @@ -96,15 +69,15 @@ class AccountPartialReconcileCashBasis(models.Model): aml.append(vals['debit_move_id']) if vals.get('credit_move_id', False): aml.append(vals['credit_move_id']) - #Get value of matched percentage from both move before reconciliating + # Get value of matched percentage from both move before reconciliating lines = self.env['account.move.line'].browse(aml) value_before_reconciliation = {} for line in lines: if not value_before_reconciliation.get(line.move_id.id, False): value_before_reconciliation[line.move_id.id] = line.move_id.matched_percentage - #Reconcile + # Reconcile res = super(AccountPartialReconcileCashBasis, self).create(vals) - #eventually create a tax cash basis entry + # eventually create a tax cash basis entry res.create_tax_cash_basis_entry(value_before_reconciliation) return res diff --git a/addons/account_tax_cash_basis/models/account_tax.py b/addons/account_tax_cash_basis/models/account_tax.py new file mode 100644 index 00000000000..aac809c20b2 --- /dev/null +++ b/addons/account_tax_cash_basis/models/account_tax.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models, fields + + +class AccountTax(models.Model): + _inherit = 'account.tax' + + use_cash_basis = fields.Boolean( + 'Use Cash Basis', + help="Select this if the tax should use cash basis," + "which will create an entry for this tax on a given account during reconciliation") + cash_basis_account = fields.Many2one( + 'account.account', + string='Tax Received Account', + domain=[('deprecated', '=', False)], + help='Account use when creating entry for tax cash basis') diff --git a/addons/account_tax_cash_basis/models/res_company.py b/addons/account_tax_cash_basis/models/res_company.py new file mode 100644 index 00000000000..cbf55554f43 --- /dev/null +++ b/addons/account_tax_cash_basis/models/res_company.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models, fields + + +class ResCompany(models.Model): + _inherit = 'res.company' + + tax_cash_basis_journal_id = fields.Many2one('account.journal', string="Tax Cash Basis Journal") diff --git a/addons/account_tax_cash_basis/views/account_config_setting_views.xml b/addons/account_tax_cash_basis/views/account_config_setting_views.xml new file mode 100644 index 00000000000..fb503fd13b1 --- /dev/null +++ b/addons/account_tax_cash_basis/views/account_config_setting_views.xml @@ -0,0 +1,16 @@ + + + + view.account.config.cash.basis.form.inherit + + account.config.settings + + +
+
+
+
+
+
\ No newline at end of file diff --git a/addons/account_tax_cash_basis/views/tax_cash_basis_view.xml b/addons/account_tax_cash_basis/views/account_tax_views.xml similarity index 52% rename from addons/account_tax_cash_basis/views/tax_cash_basis_view.xml rename to addons/account_tax_cash_basis/views/account_tax_views.xml index 001ca958973..4c661afdbc8 100644 --- a/addons/account_tax_cash_basis/views/tax_cash_basis_view.xml +++ b/addons/account_tax_cash_basis/views/account_tax_views.xml @@ -14,19 +14,5 @@
- - view.account.config.cash.basis.form.inherit - - account.config.settings - - -
-
-
-
-
-
From b370ebba0ad4f27a4f1b3313f6f3afc73947e889 Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Tue, 19 Jul 2016 11:03:54 +0200 Subject: [PATCH 06/12] [MIG] account_tax_cash_basis: replace openerp tags --- addons/account_tax_cash_basis/__openerp__.py | 1 + addons/account_tax_cash_basis/views/account_tax_views.xml | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/account_tax_cash_basis/__openerp__.py b/addons/account_tax_cash_basis/__openerp__.py index 92d8644e561..5cd7a799ada 100644 --- a/addons/account_tax_cash_basis/__openerp__.py +++ b/addons/account_tax_cash_basis/__openerp__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. + { 'name' : 'Account Tax Cash Basis', 'version' : '1.1', diff --git a/addons/account_tax_cash_basis/views/account_tax_views.xml b/addons/account_tax_cash_basis/views/account_tax_views.xml index 4c661afdbc8..869e5a54049 100644 --- a/addons/account_tax_cash_basis/views/account_tax_views.xml +++ b/addons/account_tax_cash_basis/views/account_tax_views.xml @@ -1,7 +1,5 @@ - - - + tax.form.cash.basis.inherit account.tax @@ -13,6 +11,4 @@ - - - + From aeafbb75aa3e87259043d9117250547cea6f178b Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Tue, 19 Jul 2016 11:07:19 +0200 Subject: [PATCH 07/12] [MOV] account_tax_python: reorganize files according to guidelines --- addons/account_tax_python/__init__.py | 2 +- addons/account_tax_python/__openerp__.py | 2 +- addons/account_tax_python/models/__init__.py | 4 ++++ .../{account_tax_python.py => models/account_tax.py} | 0 .../{account_tax_python.xml => views/account_tax_views.xml} | 0 5 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 addons/account_tax_python/models/__init__.py rename addons/account_tax_python/{account_tax_python.py => models/account_tax.py} (100%) rename addons/account_tax_python/{account_tax_python.xml => views/account_tax_views.xml} (100%) diff --git a/addons/account_tax_python/__init__.py b/addons/account_tax_python/__init__.py index c13faa45ed3..89d26e2f597 100644 --- a/addons/account_tax_python/__init__.py +++ b/addons/account_tax_python/__init__.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -import account_tax_python +import models diff --git a/addons/account_tax_python/__openerp__.py b/addons/account_tax_python/__openerp__.py index ee746060e97..a42f2ae97ec 100644 --- a/addons/account_tax_python/__openerp__.py +++ b/addons/account_tax_python/__openerp__.py @@ -14,6 +14,6 @@ 'version': '1.0', 'depends': ['account'], 'data': [ - 'account_tax_python.xml', + 'views/account_tax_views.xml', ], } diff --git a/addons/account_tax_python/models/__init__.py b/addons/account_tax_python/models/__init__.py new file mode 100644 index 00000000000..e5d49d4bd46 --- /dev/null +++ b/addons/account_tax_python/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import account_tax diff --git a/addons/account_tax_python/account_tax_python.py b/addons/account_tax_python/models/account_tax.py similarity index 100% rename from addons/account_tax_python/account_tax_python.py rename to addons/account_tax_python/models/account_tax.py diff --git a/addons/account_tax_python/account_tax_python.xml b/addons/account_tax_python/views/account_tax_views.xml similarity index 100% rename from addons/account_tax_python/account_tax_python.xml rename to addons/account_tax_python/views/account_tax_views.xml From 3121ced650d7a45850ab24975085aad90f988841 Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Tue, 19 Jul 2016 11:09:48 +0200 Subject: [PATCH 08/12] [MIG] account_tax_python: remove openerp tag, add license, clean imports and lint spaces --- addons/account_tax_python/__init__.py | 2 ++ addons/account_tax_python/__openerp__.py | 2 ++ addons/account_tax_python/models/account_tax.py | 10 ++++++---- addons/account_tax_python/views/account_tax_views.xml | 6 ++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/addons/account_tax_python/__init__.py b/addons/account_tax_python/__init__.py index 89d26e2f597..81fc81d29c9 100644 --- a/addons/account_tax_python/__init__.py +++ b/addons/account_tax_python/__init__.py @@ -1,2 +1,4 @@ # -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + import models diff --git a/addons/account_tax_python/__openerp__.py b/addons/account_tax_python/__openerp__.py index a42f2ae97ec..7bf983c4cc4 100644 --- a/addons/account_tax_python/__openerp__.py +++ b/addons/account_tax_python/__openerp__.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + { 'name': "Define Taxes as Python Code", 'summary': """ diff --git a/addons/account_tax_python/models/account_tax.py b/addons/account_tax_python/models/account_tax.py index 57527de81f8..286d0e27969 100644 --- a/addons/account_tax_python/models/account_tax.py +++ b/addons/account_tax_python/models/account_tax.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models, fields, api +from odoo.tools.safe_eval import safe_eval -from openerp import models, fields, api -from openerp.tools.safe_eval import safe_eval class AccountTaxPython(models.Model): _inherit = "account.tax" @@ -24,7 +26,6 @@ class AccountTaxPython(models.Model): ":param product: product.product recordset singleton or None\n" ":param partner: res.partner recordset singleton or None") - def _compute_amount(self, base_amount, price_unit, quantity=1.0, product=None, partner=None): self.ensure_one() if self.amount_type == 'code': @@ -39,7 +40,7 @@ class AccountTaxPython(models.Model): taxes = self.env['account.tax'] company = self.env.user.company_id for tax in self: - localdict = {'price_unit':price_unit, 'quantity': quantity, 'product':product, 'partner':partner, 'company': company} + localdict = {'price_unit': price_unit, 'quantity': quantity, 'product': product, 'partner': partner, 'company': company} safe_eval(tax.python_applicable, localdict, mode="exec", nocopy=True) if localdict.get('result', False): taxes += tax @@ -54,6 +55,7 @@ class AccountTaxPython(models.Model): recs = self.browse(cr, uid, ids, context=context) return AccountTaxPython.compute_all(recs, price_unit, currency, quantity, product, partner) + class AccountTaxTemplatePython(models.Model): _inherit = 'account.tax.template' diff --git a/addons/account_tax_python/views/account_tax_views.xml b/addons/account_tax_python/views/account_tax_views.xml index 94cb367fad4..7b9c70dcd64 100644 --- a/addons/account_tax_python/views/account_tax_views.xml +++ b/addons/account_tax_python/views/account_tax_views.xml @@ -1,6 +1,5 @@ - - + account.tax.form.inherited account.tax @@ -18,5 +17,4 @@ - - + From d9a5e3b3b1c580c90371631dc7a7a1847c82c5da Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Tue, 19 Jul 2016 11:24:53 +0200 Subject: [PATCH 09/12] [MOV] account_test: reorganize files according to guidelines --- addons/account_test/__init__.py | 2 +- addons/account_test/__openerp__.py | 8 ++++---- .../accounting_assert_test_data.xml} | 0 addons/account_test/models/__init__.py | 4 ++++ .../{account_test.py => models/accounting_assert_test.py} | 0 addons/account_test/report/__init__.py | 2 +- .../accounting_assert_test_reports.xml} | 0 .../{account_test_report.py => report_account_test.py} | 0 .../report_account_test_templates.xml} | 0 .../accounting_assert_test_views.xml} | 0 10 files changed, 10 insertions(+), 6 deletions(-) rename addons/account_test/{account_test_data.xml => data/accounting_assert_test_data.xml} (100%) create mode 100644 addons/account_test/models/__init__.py rename addons/account_test/{account_test.py => models/accounting_assert_test.py} (100%) rename addons/account_test/{account_test_report.xml => report/accounting_assert_test_reports.xml} (100%) rename addons/account_test/report/{account_test_report.py => report_account_test.py} (100%) rename addons/account_test/{views/report_accounttest.xml => report/report_account_test_templates.xml} (100%) rename addons/account_test/{account_test_view.xml => views/accounting_assert_test_views.xml} (100%) diff --git a/addons/account_test/__init__.py b/addons/account_test/__init__.py index 09bda7bab3d..180ebd8227c 100644 --- a/addons/account_test/__init__.py +++ b/addons/account_test/__init__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -import account_test +import models import report diff --git a/addons/account_test/__openerp__.py b/addons/account_test/__openerp__.py index d32f6f5c79b..98e3f8dd144 100644 --- a/addons/account_test/__openerp__.py +++ b/addons/account_test/__openerp__.py @@ -21,10 +21,10 @@ and print the report from Print button in header area. 'depends': ['account'], 'data': [ 'security/ir.model.access.csv', - 'account_test_view.xml', - 'account_test_report.xml', - 'account_test_data.xml', - 'views/report_accounttest.xml', + 'views/accounting_assert_test_views.xml', + 'report/accounting_assert_test_reports.xml', + 'data/accounting_assert_test_data.xml', + 'report/report_account_test_templates.xml', ], 'active': False, 'installable': True diff --git a/addons/account_test/account_test_data.xml b/addons/account_test/data/accounting_assert_test_data.xml similarity index 100% rename from addons/account_test/account_test_data.xml rename to addons/account_test/data/accounting_assert_test_data.xml diff --git a/addons/account_test/models/__init__.py b/addons/account_test/models/__init__.py new file mode 100644 index 00000000000..a1c02fa2c54 --- /dev/null +++ b/addons/account_test/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import accounting_assert_test diff --git a/addons/account_test/account_test.py b/addons/account_test/models/accounting_assert_test.py similarity index 100% rename from addons/account_test/account_test.py rename to addons/account_test/models/accounting_assert_test.py diff --git a/addons/account_test/report/__init__.py b/addons/account_test/report/__init__.py index 7977ffa557c..d0f0fb5d1a4 100644 --- a/addons/account_test/report/__init__.py +++ b/addons/account_test/report/__init__.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -import account_test_report +import report_account_test diff --git a/addons/account_test/account_test_report.xml b/addons/account_test/report/accounting_assert_test_reports.xml similarity index 100% rename from addons/account_test/account_test_report.xml rename to addons/account_test/report/accounting_assert_test_reports.xml diff --git a/addons/account_test/report/account_test_report.py b/addons/account_test/report/report_account_test.py similarity index 100% rename from addons/account_test/report/account_test_report.py rename to addons/account_test/report/report_account_test.py diff --git a/addons/account_test/views/report_accounttest.xml b/addons/account_test/report/report_account_test_templates.xml similarity index 100% rename from addons/account_test/views/report_accounttest.xml rename to addons/account_test/report/report_account_test_templates.xml diff --git a/addons/account_test/account_test_view.xml b/addons/account_test/views/accounting_assert_test_views.xml similarity index 100% rename from addons/account_test/account_test_view.xml rename to addons/account_test/views/accounting_assert_test_views.xml From 1293509ad9b1cd087282998e7eeafd88fe32d8f6 Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Tue, 19 Jul 2016 11:26:34 +0200 Subject: [PATCH 10/12] [MIG] account_test: replace openerp tag, add license, clean imports --- addons/account_test/__init__.py | 1 + addons/account_test/models/accounting_assert_test.py | 4 +++- addons/account_test/report/__init__.py | 2 ++ addons/account_test/report/report_account_test.py | 6 ++++-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/account_test/__init__.py b/addons/account_test/__init__.py index 180ebd8227c..a5f67aebd79 100644 --- a/addons/account_test/__init__.py +++ b/addons/account_test/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. + import models import report diff --git a/addons/account_test/models/accounting_assert_test.py b/addons/account_test/models/accounting_assert_test.py index f6a63b744b0..f2ee18f67df 100644 --- a/addons/account_test/models/accounting_assert_test.py +++ b/addons/account_test/models/accounting_assert_test.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- -from openerp import fields, models +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models CODE_EXEC_DEFAULT = '''\ res = [] diff --git a/addons/account_test/report/__init__.py b/addons/account_test/report/__init__.py index d0f0fb5d1a4..041b4aa6fc2 100644 --- a/addons/account_test/report/__init__.py +++ b/addons/account_test/report/__init__.py @@ -1,2 +1,4 @@ # -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + import report_account_test diff --git a/addons/account_test/report/report_account_test.py b/addons/account_test/report/report_account_test.py index 16a06622c09..a51845a799c 100644 --- a/addons/account_test/report/report_account_test.py +++ b/addons/account_test/report/report_account_test.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + import datetime -from openerp import api, models, _ -from openerp.tools.safe_eval import safe_eval as eval +from odoo import api, models, _ +from odoo.tools.safe_eval import safe_eval as eval # # Use period and Journal for selection or resources # From 9999e784a4b888336ce71023f70baa66a615d603 Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Tue, 19 Jul 2016 11:38:36 +0200 Subject: [PATCH 11/12] [MOV] account_voucher: reorganize files according to guidelines --- addons/account_voucher/__init__.py | 2 +- addons/account_voucher/__openerp__.py | 5 +- .../account_voucher/account_voucher_view.xml | 173 ------------------ .../{ => data}/account_voucher_data.xml | 0 addons/account_voucher/models/__init__.py | 4 + .../{ => models}/account_voucher.py | 0 .../account_voucher_views.xml} | 168 +++++++++++++++++ 7 files changed, 175 insertions(+), 177 deletions(-) delete mode 100644 addons/account_voucher/account_voucher_view.xml rename addons/account_voucher/{ => data}/account_voucher_data.xml (100%) create mode 100644 addons/account_voucher/models/__init__.py rename addons/account_voucher/{ => models}/account_voucher.py (100%) rename addons/account_voucher/{voucher_sales_purchase_view.xml => views/account_voucher_views.xml} (64%) diff --git a/addons/account_voucher/__init__.py b/addons/account_voucher/__init__.py index b4d48ed534e..81fc81d29c9 100644 --- a/addons/account_voucher/__init__.py +++ b/addons/account_voucher/__init__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -import account_voucher +import models diff --git a/addons/account_voucher/__openerp__.py b/addons/account_voucher/__openerp__.py index f29eb209fd6..47ad10e75e6 100644 --- a/addons/account_voucher/__openerp__.py +++ b/addons/account_voucher/__openerp__.py @@ -30,10 +30,9 @@ This module manages: 'demo' : [], 'data' : [ 'security/ir.model.access.csv', - 'account_voucher_view.xml', - 'voucher_sales_purchase_view.xml', + 'views/account_voucher_views.xml', 'security/account_voucher_security.xml', - 'account_voucher_data.xml', + 'data/account_voucher_data.xml', ], 'test' : [ 'test/account_voucher_users.yml', diff --git a/addons/account_voucher/account_voucher_view.xml b/addons/account_voucher/account_voucher_view.xml deleted file mode 100644 index 549afc73634..00000000000 --- a/addons/account_voucher/account_voucher_view.xml +++ /dev/null @@ -1,173 +0,0 @@ - - - - - account.voucher.tree - account.voucher - - - - - - - - - - - - - - account.voucher.tree.supplier - account.voucher - - - - - - - - - - - - - - - account.voucher.kanban - account.voucher - - - - - - - - - -
-
-
- -
-
- -
-
-
-
- -
-
- - - -
-
-
-
-
-
-
-
- - account.voucher.line.form - account.voucher.line - -
- - - - - - - - - - - - - - - -
- - - account.voucher.line.tree - account.voucher.line - - - - - - - - - - - - - - - - - - account.voucher.select - account.voucher - 1 - - - - - - - - - - - - - - - - - - - - - - account.voucher.graph - account.voucher - - - - - - - - - - - - Vouchers Entries - account.voucher - form - tree,form - - [('state','=','posted')] - {'state':'posted', 'voucher_type': voucher_type} - - - -
-
diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/data/account_voucher_data.xml similarity index 100% rename from addons/account_voucher/account_voucher_data.xml rename to addons/account_voucher/data/account_voucher_data.xml diff --git a/addons/account_voucher/models/__init__.py b/addons/account_voucher/models/__init__.py new file mode 100644 index 00000000000..79c19ac7bd0 --- /dev/null +++ b/addons/account_voucher/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import account_voucher \ No newline at end of file diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/models/account_voucher.py similarity index 100% rename from addons/account_voucher/account_voucher.py rename to addons/account_voucher/models/account_voucher.py diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/views/account_voucher_views.xml similarity index 64% rename from addons/account_voucher/voucher_sales_purchase_view.xml rename to addons/account_voucher/views/account_voucher_views.xml index c84b5f83081..2f4b5a37ec4 100644 --- a/addons/account_voucher/voucher_sales_purchase_view.xml +++ b/addons/account_voucher/views/account_voucher_views.xml @@ -1,6 +1,174 @@ + + account.voucher.tree + account.voucher + + + + + + + + + + + + + + account.voucher.tree.supplier + account.voucher + + + + + + + + + + + + + + + account.voucher.kanban + account.voucher + + + + + + + + + +
+
+
+ +
+
+ +
+
+
+
+ +
+
+ + + +
+
+
+
+
+
+
+
+ + account.voucher.line.form + account.voucher.line + +
+ + + + + + + + + + + + + + + +
+ + + account.voucher.line.tree + account.voucher.line + + + + + + + + + + + + + + + + + + account.voucher.select + account.voucher + 1 + + + + + + + + + + + + + + + + + + + + + + account.voucher.graph + account.voucher + + + + + + + + + + + + Vouchers Entries + account.voucher + form + tree,form + + [('state','=','posted')] + {'state':'posted', 'voucher_type': voucher_type} + + + account.voucher.purchase.select account.voucher From fe35d384ddcf94889ee4e36d535958ffe5fdef72 Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Tue, 19 Jul 2016 11:48:54 +0200 Subject: [PATCH 12/12] [MIG] account_voucher: replace opernerp tags , clean imports, rename classes, reorder code of account_voucher --- .../data/account_voucher_data.xml | 4 +- .../account_voucher/models/account_voucher.py | 147 ++++++++++-------- .../security/account_voucher_security.xml | 4 +- .../account_voucher/test/account_voucher.yml | 2 +- .../views/account_voucher_views.xml | 7 +- 5 files changed, 87 insertions(+), 77 deletions(-) diff --git a/addons/account_voucher/data/account_voucher_data.xml b/addons/account_voucher/data/account_voucher_data.xml index f3fa08d964d..8b743de5872 100644 --- a/addons/account_voucher/data/account_voucher_data.xml +++ b/addons/account_voucher/data/account_voucher_data.xml @@ -1,5 +1,5 @@ - + @@ -22,4 +22,4 @@
-
+ diff --git a/addons/account_voucher/models/account_voucher.py b/addons/account_voucher/models/account_voucher.py index 629688717a4..823785e52c4 100644 --- a/addons/account_voucher/models/account_voucher.py +++ b/addons/account_voucher/models/account_voucher.py @@ -2,12 +2,78 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from openerp import fields, models, api, _ -import openerp.addons.decimal_precision as dp -from openerp.exceptions import UserError +from odoo import fields, models, api, _ +import odoo.addons.decimal_precision as dp +from odoo.exceptions import UserError class AccountVoucher(models.Model): + _name = 'account.voucher' + _description = 'Accounting Voucher' + _inherit = ['mail.thread'] + _order = "date desc, id desc" + + @api.model + def _default_journal(self): + voucher_type = self._context.get('voucher_type', 'sale') + company_id = self._context.get('company_id', self.env.user.company_id.id) + domain = [ + ('type', '=', voucher_type), + ('company_id', '=', company_id), + ] + return self.env['account.journal'].search(domain, limit=1) + + voucher_type = fields.Selection([ + ('sale', 'Sale'), + ('purchase', 'Purchase') + ], string='Type', readonly=True, states={'draft': [('readonly', False)]}, oldname="type") + name = fields.Char('Payment Reference', + readonly=True, states={'draft': [('readonly', False)]}, default='') + date = fields.Date("Bill Date", readonly=True, + select=True, states={'draft': [('readonly', False)]}, + copy=False, default=fields.Date.context_today) + account_date = fields.Date("Accounting Date", + readonly=True, select=True, states={'draft': [('readonly', False)]}, + help="Effective date for accounting entries", copy=False, default=fields.Date.context_today) + journal_id = fields.Many2one('account.journal', 'Journal', + required=True, readonly=True, states={'draft': [('readonly', False)]}, default=_default_journal) + account_id = fields.Many2one('account.account', 'Account', + required=True, readonly=True, states={'draft': [('readonly', False)]}, + domain="[('deprecated', '=', False), ('internal_type','=', (pay_now == 'pay_now' and 'liquidity' or voucher_type == 'purchase' and 'payable' or 'receivable'))]") + line_ids = fields.One2many('account.voucher.line', 'voucher_id', 'Voucher Lines', + readonly=True, copy=True, + states={'draft': [('readonly', False)]}) + narration = fields.Text('Notes', readonly=True, states={'draft': [('readonly', False)]}) + currency_id = fields.Many2one('res.currency', compute='_get_journal_currency', + string='Currency', readonly=True, required=True, default=lambda self: self._get_currency()) + company_id = fields.Many2one('res.company', 'Company', + required=True, readonly=True, states={'draft': [('readonly', False)]}, + related='journal_id.company_id', default=lambda self: self._get_company()) + state = fields.Selection([ + ('draft', 'Draft'), + ('cancel', 'Cancelled'), + ('proforma', 'Pro-forma'), + ('posted', 'Posted') + ], 'Status', readonly=True, track_visibility='onchange', copy=False, default='draft', + help=" * The 'Draft' status is used when a user is encoding a new and unconfirmed Voucher.\n" + " * The 'Pro-forma' status is used when the voucher does not have a voucher number.\n" + " * The 'Posted' status is used when user create voucher,a voucher number is generated and voucher entries are created in account.\n" + " * The 'Cancelled' status is used when user cancel voucher.") + reference = fields.Char('Bill Reference', readonly=True, states={'draft': [('readonly', False)]}, + help="The partner reference of this document.", copy=False) + amount = fields.Monetary(string='Total', store=True, readonly=True, compute='_compute_total') + tax_amount = fields.Monetary(readonly=True, store=True, compute='_compute_total') + tax_correction = fields.Monetary(readonly=True, states={'draft': [('readonly', False)]}, + help='In case we have a rounding problem in the tax, use this field to correct it') + number = fields.Char(readonly=True, copy=False) + move_id = fields.Many2one('account.move', 'Journal Entry', copy=False) + partner_id = fields.Many2one('res.partner', 'Partner', change_default=1, readonly=True, states={'draft': [('readonly', False)]}) + paid = fields.Boolean(compute='_check_paid', help="The Voucher has been totally paid.") + pay_now = fields.Selection([ + ('pay_now', 'Pay Directly'), + ('pay_later', 'Pay Later'), + ], 'Payment', select=True, readonly=True, states={'draft': [('readonly', False)]}, default='pay_later') + date_due = fields.Date('Due Date', readonly=True, select=True, states={'draft': [('readonly', False)]}) @api.one @api.depends('move_id.line_ids.reconciled', 'move_id.line_ids.account_id.internal_type') @@ -35,16 +101,6 @@ class AccountVoucher(models.Model): def _get_journal_currency(self): self.currency_id = self.journal_id.currency_id.id or self.company_id.currency_id.id - @api.model - def _default_journal(self): - voucher_type = self._context.get('voucher_type', 'sale') - company_id = self._context.get('company_id', self.env.user.company_id.id) - domain = [ - ('type', '=', voucher_type), - ('company_id', '=', company_id), - ] - return self.env['account.journal'].search(domain, limit=1) - @api.multi @api.depends('tax_correction', 'line_ids.price_subtotal') def _compute_total(self): @@ -63,50 +119,6 @@ class AccountVoucher(models.Model): def _get_account(self): self.account_id = self.account_pay_now_id if self.pay_now == 'pay_now' else self.account_pay_later_id - _name = 'account.voucher' - _description = 'Accounting Voucher' - _inherit = ['mail.thread'] - _order = "date desc, id desc" - - voucher_type = fields.Selection([('sale', 'Sale'), ('purchase', 'Purchase')], string='Type', readonly=True, states={'draft': [('readonly', False)]}, oldname="type") - name = fields.Char('Payment Reference', readonly=True, states={'draft': [('readonly', False)]}, default='') - date = fields.Date("Bill Date", readonly=True, select=True, states={'draft': [('readonly', False)]}, - copy=False, default=fields.Date.context_today) - account_date = fields.Date("Accounting Date", readonly=True, select=True, states={'draft': [('readonly', False)]}, - help="Effective date for accounting entries", copy=False, default=fields.Date.context_today) - journal_id = fields.Many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft': [('readonly', False)]}, default=_default_journal) - account_id = fields.Many2one('account.account', 'Account', required=True, readonly=True, states={'draft': [('readonly', False)]}, domain="[('deprecated', '=', False), ('internal_type','=', (pay_now == 'pay_now' and 'liquidity' or voucher_type == 'purchase' and 'payable' or 'receivable'))]") - line_ids = fields.One2many('account.voucher.line', 'voucher_id', 'Voucher Lines', - readonly=True, copy=True, - states={'draft': [('readonly', False)]}) - narration = fields.Text('Notes', readonly=True, states={'draft': [('readonly', False)]}) - currency_id = fields.Many2one('res.currency', compute='_get_journal_currency', string='Currency', readonly=True, required=True, default=lambda self: self._get_currency()) - company_id = fields.Many2one('res.company', 'Company', required=True, readonly=True, states={'draft': [('readonly', False)]}, related='journal_id.company_id', default=lambda self: self._get_company()) - state = fields.Selection( - [('draft', 'Draft'), - ('cancel', 'Cancelled'), - ('proforma', 'Pro-forma'), - ('posted', 'Posted') - ], 'Status', readonly=True, track_visibility='onchange', copy=False, default='draft', - help=" * The 'Draft' status is used when a user is encoding a new and unconfirmed Voucher.\n" - " * The 'Pro-forma' status is used when the voucher does not have a voucher number.\n" - " * The 'Posted' status is used when user create voucher,a voucher number is generated and voucher entries are created in account.\n" - " * The 'Cancelled' status is used when user cancel voucher.") - reference = fields.Char('Bill Reference', readonly=True, states={'draft': [('readonly', False)]}, - help="The partner reference of this document.", copy=False) - amount = fields.Monetary(string='Total', store=True, readonly=True, compute='_compute_total') - tax_amount = fields.Monetary(readonly=True, store=True, compute='_compute_total') - tax_correction = fields.Monetary(readonly=True, states={'draft': [('readonly', False)]}, help='In case we have a rounding problem in the tax, use this field to correct it') - number = fields.Char(readonly=True, copy=False) - move_id = fields.Many2one('account.move', 'Journal Entry', copy=False) - partner_id = fields.Many2one('res.partner', 'Partner', change_default=1, readonly=True, states={'draft': [('readonly', False)]}) - paid = fields.Boolean(compute='_check_paid', help="The Voucher has been totally paid.") - pay_now = fields.Selection([ - ('pay_now', 'Pay Directly'), - ('pay_later', 'Pay Later'), - ], 'Payment', select=True, readonly=True, states={'draft': [('readonly', False)]}, default='pay_later') - date_due = fields.Date('Due Date', readonly=True, select=True, states={'draft': [('readonly', False)]}) - @api.onchange('date') def onchange_date(self): self.account_date = self.date @@ -235,7 +247,8 @@ class AccountVoucher(models.Model): if not line.price_subtotal: continue # convert the amount set on the voucher line into the currency of the voucher's company - # this calls res_curreny.compute() with the right context, so that it will take either the rate on the voucher if it is relevant or will use the default behaviour + # this calls res_curreny.compute() with the right context, + # so that it will take either the rate on the voucher if it is relevant or will use the default behaviour amount = self._convert_amount(line.price_unit*line.quantity) move_line = { 'journal_id': self.journal_id.id, @@ -307,18 +320,10 @@ class AccountVoucher(models.Model): return super(AccountVoucher, self)._track_subtype(init_values) -class account_voucher_line(models.Model): +class AccountVoucherLine(models.Model): _name = 'account.voucher.line' _description = 'Voucher Lines' - @api.one - @api.depends('price_unit', 'tax_ids', 'quantity', 'product_id', 'voucher_id.currency_id') - def _compute_subtotal(self): - self.price_subtotal = self.quantity * self.price_unit - if self.tax_ids: - taxes = self.tax_ids.compute_all(self.price_unit, self.voucher_id.currency_id, self.quantity, product=self.product_id, partner=self.voucher_id.partner_id) - self.price_subtotal = taxes['total_excluded'] - name = fields.Text(string='Description', required=True) sequence = fields.Integer(default=10, help="Gives the sequence of this line when displaying the voucher.") @@ -338,6 +343,14 @@ class account_voucher_line(models.Model): tax_ids = fields.Many2many('account.tax', string='Tax', help="Only for tax excluded from price") currency_id = fields.Many2one('res.currency', related='voucher_id.currency_id') + @api.one + @api.depends('price_unit', 'tax_ids', 'quantity', 'product_id', 'voucher_id.currency_id') + def _compute_subtotal(self): + self.price_subtotal = self.quantity * self.price_unit + if self.tax_ids: + taxes = self.tax_ids.compute_all(self.price_unit, self.voucher_id.currency_id, self.quantity, product=self.product_id, partner=self.voucher_id.partner_id) + self.price_subtotal = taxes['total_excluded'] + def _get_account(self, product, fpos, type): accounts = product.product_tmpl_id.get_product_accounts(fpos) if type == 'sale': diff --git a/addons/account_voucher/security/account_voucher_security.xml b/addons/account_voucher/security/account_voucher_security.xml index daa5934b256..c32e720f67e 100644 --- a/addons/account_voucher/security/account_voucher_security.xml +++ b/addons/account_voucher/security/account_voucher_security.xml @@ -1,5 +1,5 @@ - + Voucher multi-company @@ -14,4 +14,4 @@ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] - + diff --git a/addons/account_voucher/test/account_voucher.yml b/addons/account_voucher/test/account_voucher.yml index f1ad9033f4c..727e5366443 100644 --- a/addons/account_voucher/test/account_voucher.yml +++ b/addons/account_voucher/test/account_voucher.yml @@ -5,7 +5,7 @@ uid: 'res_users_account_voucher_user' - - In order to check account voucher module in OpenERP I create a customer voucher + In order to check account voucher module in Odoo I create a customer voucher - !record {model: account.voucher, id: account_voucher_voucherforaxelor0, view: view_sale_receipt_form}: voucher_type: sale diff --git a/addons/account_voucher/views/account_voucher_views.xml b/addons/account_voucher/views/account_voucher_views.xml index 2f4b5a37ec4..2bdf99ec1e9 100644 --- a/addons/account_voucher/views/account_voucher_views.xml +++ b/addons/account_voucher/views/account_voucher_views.xml @@ -1,6 +1,5 @@ - - + account.voucher.tree account.voucher @@ -436,6 +435,4 @@ - - - +