diff --git a/l10n_be_invoice_bba_supplier/__init__.py b/l10n_be_invoice_bba_supplier/__init__.py index 0650744f..e69de29b 100644 --- a/l10n_be_invoice_bba_supplier/__init__.py +++ b/l10n_be_invoice_bba_supplier/__init__.py @@ -1 +0,0 @@ -from . import models diff --git a/l10n_be_invoice_bba_supplier/__manifest__.py b/l10n_be_invoice_bba_supplier/__manifest__.py index 7fb4c6f2..179abc87 100644 --- a/l10n_be_invoice_bba_supplier/__manifest__.py +++ b/l10n_be_invoice_bba_supplier/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Supplier payment with Belgian structured communication', - 'version': '11.0.1.0.0', + 'version': '11.0.1.2.0', 'category': 'Accounting & Finance', 'website': 'https://www.noviat.com', 'author': 'Noviat', @@ -12,6 +12,7 @@ 'views/account_invoice.xml', ], 'depends': [ + 'account_supplier_invoice_number', 'l10n_be_invoice_bba', ], 'installable': True, diff --git a/l10n_be_invoice_bba_supplier/models/__init__.py b/l10n_be_invoice_bba_supplier/models/__init__.py deleted file mode 100644 index 8e072db8..00000000 --- a/l10n_be_invoice_bba_supplier/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import account_invoice diff --git a/l10n_be_invoice_bba_supplier/models/account_invoice.py b/l10n_be_invoice_bba_supplier/models/account_invoice.py deleted file mode 100644 index f68d1b24..00000000 --- a/l10n_be_invoice_bba_supplier/models/account_invoice.py +++ /dev/null @@ -1,72 +0,0 @@ -# Copyright 2009-2019 Noviat. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -import re - -from odoo import api, fields, models, _ -from odoo.exceptions import ValidationError - - -class AccountInvoice(models.Model): - _inherit = 'account.invoice' - - supplier_payment_ref_type = fields.Selection( - selection='_selection_supplier_payment_ref_type', - string='Payment Reference Type', - required=True, default='normal') - supplier_payment_ref = fields.Char( - string='Payment Reference', - help="Payment reference for use within payment orders.") - - @api.model - def _selection_supplier_payment_ref_type(self): - return [ - ('normal', _('Free Communication')), - ('bba', _('BBA Structured Communication'))] - - @api.constrains('supplier_payment_ref_type', 'supplier_payment_ref') - def _check_communication(self): - for inv in self: - if inv.supplier_payment_ref_type == 'bba' \ - and not self.check_bbacomm(inv.supplier_payment_ref): - raise ValidationError( - _("Invalid BBA Structured Communication !")) - - @api.onchange('supplier_payment_ref_type', 'reference') - def _onchange_reference(self): - if self.type == 'in_invoice' \ - and self.supplier_payment_ref_type == 'normal': - self.supplier_payment_ref = self.reference - - @api.model - def create(self, vals): - if vals.get('supplier_payment_ref_type') == 'bba' \ - and self._context.get('type') == 'in_invoice': - pay_ref = vals.get('supplier_payment_ref') - if self.check_bbacomm(pay_ref): - vals['supplier_payment_ref'] = self._format_bbacomm(pay_ref) - return super().create(vals) - - @api.multi - def write(self, vals): - for inv in self: - if inv.state == 'draft': - if 'supplier_payment_ref_type' in vals: - pay_ref_type = vals['supplier_payment_ref_type'] - else: - pay_ref_type = inv.supplier_payment_ref_type - if pay_ref_type == 'bba': - if 'supplier_payment_ref' in vals: - bbacomm = vals['supplier_payment_ref'] - else: - bbacomm = inv.supplier_payment_ref or '' - if self.check_bbacomm(bbacomm): - vals['supplier_payment_ref'] = self._format_bbacomm( - bbacomm) - return super().write(vals) - - def _format_bbacomm(self, val): - bba = re.sub('\D', '', val) - bba = '+++%s/%s/%s+++' % ( - bba[0:3], bba[3:7], bba[7:]) - return bba diff --git a/l10n_be_invoice_bba_supplier/views/account_invoice.xml b/l10n_be_invoice_bba_supplier/views/account_invoice.xml index a02f31f5..9b2206ff 100644 --- a/l10n_be_invoice_bba_supplier/views/account_invoice.xml +++ b/l10n_be_invoice_bba_supplier/views/account_invoice.xml @@ -6,13 +6,14 @@ account.invoice - - - - - - + + Communication Type + Payment Communication Type + + + Communication + Payment Communication +