diff --git a/addons/account_check_printing/__init__.py b/addons/account_check_printing/__init__.py index 86524733c84..11529f98733 100644 --- a/addons/account_check_printing/__init__.py +++ b/addons/account_check_printing/__init__.py @@ -1,7 +1,5 @@ # -*- 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 - +import models import wizard diff --git a/addons/account_check_printing/__openerp__.py b/addons/account_check_printing/__openerp__.py index c3d380b4fdd..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', @@ -10,13 +12,12 @@ 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_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/account_journal_dashboard.py b/addons/account_check_printing/account_journal_dashboard.py deleted file mode 100644 index 3b1fc1b93cc..00000000000 --- a/addons/account_check_printing/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/data/check_printing.xml b/addons/account_check_printing/data/account_check_printing_data.xml similarity index 98% rename from addons/account_check_printing/data/check_printing.xml rename to addons/account_check_printing/data/account_check_printing_data.xml index 48dbad8c15d..4fd632173af 100644 --- a/addons/account_check_printing/data/check_printing.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/__init__.py b/addons/account_check_printing/models/__init__.py new file mode 100644 index 00000000000..b07a9ea0961 --- /dev/null +++ b/addons/account_check_printing/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import account_journal +import account_payment diff --git a/addons/account_check_printing/account_journal.py b/addons/account_check_printing/models/account_journal.py similarity index 73% rename from addons/account_check_printing/account_journal.py rename to addons/account_check_printing/models/account_journal.py index 7470787d322..6bdc23269af 100644 --- a/addons/account_check_printing/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" @@ -76,3 +77,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/account_payment.py b/addons/account_check_printing/models/account_payment.py similarity index 84% rename from addons/account_check_printing/account_payment.py rename to addons/account_check_printing/models/account_payment.py index 68850f7c206..30019379029 100644 --- a/addons/account_check_printing/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_view.xml b/addons/account_check_printing/views/account_journal_view.xml deleted file mode 100644 index 9f180bb099b..00000000000 --- a/addons/account_check_printing/views/account_journal_view.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - account.journal.form.inherited - account.journal - - - - - - - - - - - - - - diff --git a/addons/account_check_printing/views/account_journal_dashboard_view.xml b/addons/account_check_printing/views/account_journal_views.xml similarity index 54% rename from addons/account_check_printing/views/account_journal_dashboard_view.xml rename to addons/account_check_printing/views/account_journal_views.xml index 8ce220b7eee..11bcb277b5a 100644 --- a/addons/account_check_printing/views/account_journal_dashboard_view.xml +++ b/addons/account_check_printing/views/account_journal_views.xml @@ -1,5 +1,5 @@ - - + + account.journal.dashboard.kanban.inherited account.journal @@ -20,5 +20,20 @@ - - + + + account.journal.form.inherited + account.journal + + + + + + + + + + + + + diff --git a/addons/account_check_printing/views/account_payment_view.xml b/addons/account_check_printing/views/account_payment_views.xml similarity index 98% rename from addons/account_check_printing/views/account_payment_view.xml rename to addons/account_check_printing/views/account_payment_views.xml index 33fd221cda5..f54a93ea0b2 100644 --- a/addons/account_check_printing/views/account_payment_view.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 0d305b91dc3..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_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 75% rename from addons/account_check_printing/wizard/print_pre_numbered_checks.py rename to addons/account_check_printing/wizard/print_prenumbered_checks.py index 4bf1d912bda..79af6f69dd0 100644 --- a/addons/account_check_printing/wizard/print_pre_numbered_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_pre_numbered_checks.xml b/addons/account_check_printing/wizard/print_prenumbered_checks_views.xml similarity index 95% rename from addons/account_check_printing/wizard/print_pre_numbered_checks.xml rename to addons/account_check_printing/wizard/print_prenumbered_checks_views.xml index 482462a5017..9b136b3a8dc 100644 --- a/addons/account_check_printing/wizard/print_pre_numbered_checks.xml +++ b/addons/account_check_printing/wizard/print_prenumbered_checks_views.xml @@ -1,6 +1,5 @@ - - + Print Pre-numbered Checks @@ -21,5 +20,4 @@ - - + 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/__openerp__.py b/addons/account_tax_cash_basis/__openerp__.py index c6de2ca37a6..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', @@ -13,7 +14,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 new file mode 100644 index 00000000000..79092458d54 --- /dev/null +++ b/addons/account_tax_cash_basis/models/__init__.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +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/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/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/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/account_tax_views.xml b/addons/account_tax_cash_basis/views/account_tax_views.xml new file mode 100644 index 00000000000..869e5a54049 --- /dev/null +++ b/addons/account_tax_cash_basis/views/account_tax_views.xml @@ -0,0 +1,14 @@ + + + + tax.form.cash.basis.inherit + account.tax + + + + + + + + + diff --git a/addons/account_tax_cash_basis/views/tax_cash_basis_view.xml b/addons/account_tax_cash_basis/views/tax_cash_basis_view.xml deleted file mode 100644 index 001ca958973..00000000000 --- a/addons/account_tax_cash_basis/views/tax_cash_basis_view.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - tax.form.cash.basis.inherit - account.tax - - - - - - - - - - - view.account.config.cash.basis.form.inherit - - account.config.settings - - -
-
-
-
-
- -
-
diff --git a/addons/account_tax_python/__init__.py b/addons/account_tax_python/__init__.py index c13faa45ed3..81fc81d29c9 100644 --- a/addons/account_tax_python/__init__.py +++ b/addons/account_tax_python/__init__.py @@ -1,2 +1,4 @@ # -*- coding: utf-8 -*- -import account_tax_python +# 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 ee746060e97..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': """ @@ -14,6 +16,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 93% rename from addons/account_tax_python/account_tax_python.py rename to addons/account_tax_python/models/account_tax.py index 57527de81f8..286d0e27969 100644 --- a/addons/account_tax_python/account_tax_python.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/account_tax_python.xml b/addons/account_tax_python/views/account_tax_views.xml similarity index 95% rename from addons/account_tax_python/account_tax_python.xml rename to addons/account_tax_python/views/account_tax_views.xml index 94cb367fad4..7b9c70dcd64 100644 --- a/addons/account_tax_python/account_tax_python.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 @@ - - + diff --git a/addons/account_test/__init__.py b/addons/account_test/__init__.py index 09bda7bab3d..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 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 85% rename from addons/account_test/account_test.py rename to addons/account_test/models/accounting_assert_test.py index f6a63b744b0..f2ee18f67df 100644 --- a/addons/account_test/account_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 7977ffa557c..041b4aa6fc2 100644 --- a/addons/account_test/report/__init__.py +++ b/addons/account_test/report/__init__.py @@ -1,2 +1,4 @@ # -*- coding: utf-8 -*- -import account_test_report +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +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 94% rename from addons/account_test/report/account_test_report.py rename to addons/account_test/report/report_account_test.py index 16a06622c09..a51845a799c 100644 --- a/addons/account_test/report/account_test_report.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 # 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 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 98% rename from addons/account_voucher/account_voucher_data.xml rename to addons/account_voucher/data/account_voucher_data.xml index f3fa08d964d..8b743de5872 100644 --- a/addons/account_voucher/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/__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 86% rename from addons/account_voucher/account_voucher.py rename to addons/account_voucher/models/account_voucher.py index 629688717a4..823785e52c4 100644 --- a/addons/account_voucher/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/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..2bdf99ec1e9 100644 --- a/addons/account_voucher/voucher_sales_purchase_view.xml +++ b/addons/account_voucher/views/account_voucher_views.xml @@ -1,6 +1,173 @@ - - + + + 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 @@ -268,6 +435,4 @@ - -
-
+