Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] l10n_be_cooperator_national_number #119

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0531c6a
[ADD] l10n_be_cooperator_national_number
victor-champonnois Feb 8, 2023
f77e653
[ADD] l10n_be_cooperator_website_national_number
victor-champonnois Feb 23, 2023
ad29dd2
run black
victor-champonnois Feb 23, 2023
57ff13a
[UPD] Update l10n_be_cooperator_national_number.pot
Feb 23, 2023
5bde3f4
[UPD] README.rst
OCA-git-bot Feb 23, 2023
9fd0aee
[ADD] icon.png
OCA-git-bot Feb 23, 2023
13f4361
[IMP] l10n_be_cooperator_national_number: black, isort, prettier
carmenbianca May 23, 2023
246ff01
[MIG] l10n_be_cooperator_national_number: Migration to 13.0
carmenbianca May 23, 2023
a62e73e
[MIG] l10n_be_cooperator_national_number: Migration to 14.0
carmenbianca May 23, 2023
3b21a3c
[FIX] l10n_be_cooperator_national_number: Stop using deprecated _comp…
carmenbianca May 23, 2023
19f2de0
[REF] l10n_be_cooperator_national_number: Separate display from require
carmenbianca May 31, 2023
b78317a
[FIX] l10n_be_cooperator_national_number: Repair failing migration
carmenbianca Jun 15, 2023
8f8fbfe
[IMP] use double quotes in user-facing message
huguesdk Jun 23, 2023
ec18fb5
[FIX] l10n_be_cooperator_national_number: Don't write non-existent fi…
carmenbianca Jun 29, 2023
3e5ccb1
[FIX] l10n_be_cooperator_national_number: Write national number even …
carmenbianca Jul 17, 2023
9714f38
[FIX] l10n_be_cooperator_national_number: Fix the tests
carmenbianca Jul 17, 2023
b710c95
[IMP] l10n_be_cooperator_national_number: black, isort, prettier
victor-champonnois Mar 15, 2024
b5de53a
[MIG] l10n_be_cooperator_national_number: Migration to 15.0
victor-champonnois Mar 15, 2024
56f29ab
[MIG] l10n_be_cooperator_national_number: Migration to 16.0
victor-champonnois Mar 15, 2024
39bdd4d
[REF] depends on l10n_be_partner_identification
victor-champonnois Mar 15, 2024
5205fca
[REF] cooperator: Rename method
carmenbianca Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cooperator/models/subscription_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def _compute_subscription_amount(self):

_order = "id desc"

def get_person_info(self, partner):
def set_person_info(self, partner):
self.firstname = partner.firstname
self.name = partner.name
self.lastname = partner.lastname
Expand Down Expand Up @@ -504,10 +504,10 @@ def onchange_partner(self):
self.company_email = partner.email
self.company_register_number = partner.company_register_number
representative = partner.get_representative()
self.get_person_info(representative)
self.set_person_info(representative)
self.contact_person_function = representative.function
else:
self.get_person_info(partner)
self.set_person_info(partner)

# fixme: this is very specific and should not be here.
# declare this function in order to be overriden
Expand Down
84 changes: 84 additions & 0 deletions l10n_be_cooperator_national_number/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
===================================
Belgium: Cooperator National Number
===================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:630e1017f61be213540b60239befca6d9dc713c41118f2a603254d70f4b9ec7f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcooperative-lightgray.png?logo=github
:target: https://github.com/OCA/cooperative/tree/16.0/l10n_be_cooperator_national_number
:alt: OCA/cooperative
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/cooperative-16-0/cooperative-16-0-l10n_be_cooperator_national_number
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/cooperative&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Ask for Belgian National Number in Subscription Request.

**Table of contents**

.. contents::
:local:

Usage
=====

On the company, two new toggles 'Display National Number' and 'Require National
Number' are added. In order to expose the functionality of this module, you must
enable these toggles for every company that wishes to use it. 'Display' shows
the field and allows it to be filled in. 'Require' makes the field mandatory.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/cooperative/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/cooperative/issues/new?body=module:%20l10n_be_cooperator_national_number%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Coop IT Easy SC

Contributors
~~~~~~~~~~~~

* Coop IT Easy SC

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/cooperative <https://github.com/OCA/cooperative/tree/16.0/l10n_be_cooperator_national_number>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions l10n_be_cooperator_national_number/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions l10n_be_cooperator_national_number/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2018 Coop IT Easy SC (<http://www.coopiteasy.be>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).#
{
"name": "Belgium: Cooperator National Number",
"summary": "Ask for Belgian National Number in Cooperative Subscription Request.",
"version": "16.0.1.0.0",
"depends": ["cooperator", "l10n_be_partner_identification"],
"author": "Coop IT Easy SC, Odoo Community Association (OCA)",
"category": "Cooperative management",
"website": "https://github.com/OCA/cooperative",
"license": "AGPL-3",
"data": ["views/subscription_request_view.xml", "views/res_company_view.xml"],
"demo": [],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_be_cooperator_national_number
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: l10n_be_cooperator_national_number
#: model:ir.model,name:l10n_be_cooperator_national_number.model_res_company
msgid "Companies"
msgstr ""

#. module: l10n_be_cooperator_national_number
#: model:ir.model.fields,field_description:l10n_be_cooperator_national_number.field_subscription_request__display_national_number
msgid "Display National Number"
msgstr ""

#. module: l10n_be_cooperator_national_number
#: model:ir.model.fields,field_description:l10n_be_cooperator_national_number.field_subscription_request__national_number
msgid "National Number"
msgstr ""

#. module: l10n_be_cooperator_national_number
#: code:addons/l10n_be_cooperator_national_number/models/subscription_request.py:38
#, python-format
msgid "National Number is required."
msgstr ""

#. module: l10n_be_cooperator_national_number
#: model:ir.model.fields,field_description:l10n_be_cooperator_national_number.field_res_company__require_national_number
msgid "Require National Number"
msgstr ""

#. module: l10n_be_cooperator_national_number
#: model:ir.model,name:l10n_be_cooperator_national_number.model_subscription_request
msgid "Subscription Request"
msgstr ""

3 changes: 3 additions & 0 deletions l10n_be_cooperator_national_number/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import company
from . import subscription_request
from . import res_partner
30 changes: 30 additions & 0 deletions l10n_be_cooperator_national_number/models/company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2019 Coop IT Easy SCRL fs
# Houssine Bakkali <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).


from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


class ResCompany(models.Model):
_inherit = "res.company"

display_national_number = fields.Boolean()
require_national_number = fields.Boolean()

@api.constrains("display_national_number", "require_national_number")
def _check_national_number(self):
for company in self:
if company.require_national_number and not company.display_national_number:
raise ValidationError(
_(
'If the "Require National Number" toggle is enabled,'
' then so must the "Display National Number" toggle.'
)
)

@api.onchange("display_national_number")
def _onchange_display_national_number(self):
if not self.display_national_number:
self.require_national_number = False
36 changes: 36 additions & 0 deletions l10n_be_cooperator_national_number/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-FileCopyrightText: 2023 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

from odoo import models


class ResPartner(models.Model):
_inherit = "res.partner"

def update_belgian_national_number(self, national_number):
self.ensure_one()
result = None
if national_number:
belgian_cat = self.env.ref(
"l10n_be_partner_identification.l10n_be_national_registry_number_category"
)
existing = self.env["res.partner.id_number"].search(
[
("partner_id", "=", self.id),
("category_id", "=", belgian_cat.id),
]
)
# Update
if existing:
existing.name = national_number
result = existing
# Create new
else:
values = {
"name": national_number,
"category_id": belgian_cat.id,
"partner_id": self.id,
}
result = self.env["res.partner.id_number"].create(values)
return result
50 changes: 50 additions & 0 deletions l10n_be_cooperator_national_number/models/subscription_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from odoo import _, api, fields, models
from odoo.exceptions import UserError


class SubscriptionRequest(models.Model):
_inherit = "subscription.request"

national_number = fields.Char()
display_national_number = fields.Boolean(
compute="_compute_display_national_number",
)
require_national_number = fields.Boolean(
compute="_compute_require_national_number",
)

@api.depends("is_company", "company_id", "company_id.display_national_number")
def _compute_display_national_number(self):
self.display_national_number = (
self.company_id.display_national_number and not self.is_company
)

@api.depends("is_company", "company_id", "company_id.require_national_number")
def _compute_require_national_number(self):
self.require_national_number = (
self.company_id.require_national_number and not self.is_company
)

def get_national_number_from_partner(self, partner):
national_number_id_category = self.env.ref(
"l10n_be_partner_identification.l10n_be_national_registry_number_category"
).id
national_number = partner.id_numbers.filtered(
lambda rec: rec.category_id.id == national_number_id_category
)
return national_number.name

def validate_subscription_request(self):
self.ensure_one()
if self.require_national_number and not self.national_number:
raise UserError(_("National Number is required."))
invoice = super().validate_subscription_request()
if not self.is_company:
partner = invoice.partner_id
partner.update_belgian_national_number(self.national_number)
return invoice

def set_person_info(self, partner):
super().set_person_info(partner)
self.national_number = self.get_national_number_from_partner(partner)
return True
1 change: 1 addition & 0 deletions l10n_be_cooperator_national_number/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Coop IT Easy SC
1 change: 1 addition & 0 deletions l10n_be_cooperator_national_number/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ask for Belgian National Number in Subscription Request.
4 changes: 4 additions & 0 deletions l10n_be_cooperator_national_number/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
On the company, two new toggles 'Display National Number' and 'Require National
Number' are added. In order to expose the functionality of this module, you must
enable these toggles for every company that wishes to use it. 'Display' shows
the field and allows it to be filled in. 'Require' makes the field mandatory.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading