Skip to content

Commit

Permalink
Merge 7b4c083 into 7b3e2b8
Browse files Browse the repository at this point in the history
  • Loading branch information
astirpe authored May 23, 2019
2 parents 7b3e2b8 + 7b4c083 commit 0fbd0e8
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 6 deletions.
4 changes: 2 additions & 2 deletions l10n_nl_bsn/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright 2016-2018 Onestein (<https://www.onestein.eu>)
# Copyright 2016-2019 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
'name': 'Burgerservicenummer (BSN) for Partners',
'version': '12.0.1.0.0',
'version': '12.0.1.0.1',
'development_status': 'Production/Stable',
'category': 'Localization',
'author': 'Onestein, Odoo Community Association (OCA)',
Expand Down
30 changes: 29 additions & 1 deletion l10n_nl_bsn/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Copyright 2016-2018 Onestein (<https://www.onestein.eu>)
# Copyright 2016-2019 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import logging

from odoo import api, fields, models, _
from odoo.osv import expression

_logger = logging.getLogger(__name__)
try:
Expand Down Expand Up @@ -66,3 +67,30 @@ def _warn_bsn_existing(self):
'message': msg % (self.name, self.bsn_number)
}
return warning

@api.model
def search(self, args, offset=0, limit=None, order=None, count=False):
res_domain = []
for domain in args:
if (
len(domain) > 2 and domain[0] == 'bsn_number' and
isinstance(domain[2], str) and domain[2]
):
operator = domain[1]
bsn_number = domain[2]
bsn_compact = bsn.compact(bsn_number)
bsn_domain = expression.OR([
[('bsn_number', operator, bsn_number)],
[('bsn_number', operator, bsn_compact)],
])
if bsn.is_valid(bsn_number):
bsn_format = bsn.format(bsn_number)
bsn_domain = expression.OR([
bsn_domain,
[('bsn_number', operator, bsn_format)],
])
res_domain += bsn_domain
else:
res_domain.append(domain)
return super().search(
res_domain, offset=offset, limit=limit, order=order, count=count)
3 changes: 3 additions & 0 deletions l10n_nl_bsn/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* The 'ilike' search of a substring of a BSN number could not work properly in case the
entered BSN number does not contain dots while the corresponding BSN number stored in the
database contains dots.
37 changes: 36 additions & 1 deletion l10n_nl_bsn/tests/test_l10n_nl_bsn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017-2018 Onestein (<https://www.onestein.eu>)
# Copyright 2017-2019 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.tests.common import TransactionCase
Expand Down Expand Up @@ -48,3 +48,38 @@ def test_03_bsn_another_partner(self):
title = warning.get('title')
self.assertTrue(title)
self.assertEqual(title, 'Warning!')

def test_04_search_bsn_number(self):
self.partner_bsn.bsn_number = '100000009'
self.partner_bsn.onchange_bsn_number()
self.partner_bsn.write({})
self.assertEqual(self.partner_bsn.bsn_number, '1000.00.009')

res = self.env['res.partner'].search([
('bsn_number', '=', '100000009'),
])
self.assertEqual(len(res), 1)
res = self.env['res.partner'].search([
('bsn_number', '=', '1000.00.009'),
])
self.assertEqual(len(res), 1)
res = self.env['res.partner'].search([
('bsn_number', 'ilike', '1000.00.00'),
])
self.assertEqual(len(res), 1)
res = self.env['res.partner'].search([
('bsn_number', 'ilike', '00.00.009'),
])
self.assertEqual(len(res), 1)
res = self.env['res.partner'].search([
('bsn_number', 'ilike', '00.00.00'),
])
self.assertEqual(len(res), 1)
res = self.env['res.partner'].search([
('bsn_number', '=', '10000000'),
])
self.assertFalse(res)
res = self.env['res.partner'].search([
('bsn_number', '=', '1000.00.00'),
])
self.assertFalse(res)
4 changes: 2 additions & 2 deletions l10n_nl_tax_statement/tests/test_l10n_nl_vat_statement.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017-2018 Onestein (<https://www.onestein.eu>)
# Copyright 2017-2019 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import datetime
Expand Down Expand Up @@ -403,7 +403,7 @@ def test_15_invoice_basis_undeclared_invoice(self):
self.statement_1.company_id.country_id = self.env.ref('base.nl')

invoice2 = self.invoice_1.copy()
old_date = fields.Date.today() + relativedelta(months=-4, day=1)
old_date = fields.Date.from_string('2018-12-07')
invoice2.date_invoice = old_date
invoice2.action_invoice_open()

Expand Down

0 comments on commit 0fbd0e8

Please sign in to comment.