Skip to content

Conversation

@mihien
Copy link

@mihien mihien commented Sep 28, 2025

The current legal_form field that represents the company types is currently hard coded in each localization module and can not be modified by the user to add or remove a value.

Replacing this value by the OCA module partner_company_type, makes this field more generic. Simplifying localization which now requires just either a module data or can be added directly from the user interface.

edit (by @huguesdk): this depends on:

@mihien mihien force-pushed the 16.0-ref-cooperator-company_type branch from bf495c1 to 36ec27f Compare September 28, 2025 17:16
Copy link
Member

@huguesdk huguesdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly lgtm, thanks for this, @mihien!

small but important problem: after filling the /become_company_cooperator form, the selected company type is not set on the subscription request. for this to work, you need to modify cooperator_website/views/subscription_template.xml and replace any occurence of company_type by partner_company_type_id.

Comment on lines 1397 to 1398
# an existing type cannot be used because they are only defined in
# localization modules.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment should be removed.

"name": "Cooperators Belgium",
"summary": "Cooperators Belgium Localization",
"version": "16.0.1.2.1",
"version": "16.0.3.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"version": "16.0.3.0.0",
"version": "16.0.2.0.0",



def migrate(cr, version):

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

there shouldn’t be a blank line here.

Comment on lines 10 to 11
# module. We're using the fact that the label of the legal_form selection
# field is the same as the ids of the records in l10n_be_company_types.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# module. We're using the fact that the label of the legal_form selection
# field is the same as the ids of the records in l10n_be_company_types.
# module. We're using the fact that the values of the legal_form selection
# field are the same as the xml ids of the records in l10n_be_partner_company_type.



def migrate(cr, version):

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines 22 to 31
# Remove the old values in res_partner.legal_form to prepare the database for
# those fields to be deleted. Otherwise the values added by add_selection
# will not be valid anymore but would still be present in the db.
cr.execute(
"""
UPDATE res_partner
SET legal_form = NULL
"""
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed? the column will be deleted no matter what. same remark for subscription_request.company_type.

company_types_records = (
request.env["res.partner.company.type"].sudo().search([])
)
company_types = [(record.id, record.name) for record in company_types_records]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it would be a good addition to also display the abbreviation next to the name:

Suggested change
company_types = [(record.id, record.name) for record in company_types_records]
company_types = [
(
record.id,
"{name} ({abbr})".format(name=record.name, abbr=record.shortcut),
)
for record in company_types_records
]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, i’m not so sure about this. maybe this should be changed directly in the partner_company_type module (for example, having a “display name” field), to ensure consistency (also in the internal partner forms, for example).

values["company_name"] = partner.name
values["company_email"] = partner.email
values["company_type"] = partner.legal_form
values["partner_company_type_id"] = partner.partner_company_type_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
values["partner_company_type_id"] = partner.partner_company_type_id
values["partner_company_type_id"] = partner.partner_company_type_id.id

values["products"] = products
fields_desc = sub_req_obj.sudo().fields_get(["company_type", "gender"])
values["company_types"] = fields_desc["company_type"]["selection"]
values["company_types"] = self.get_company_types()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
values["company_types"] = self.get_company_types()
values["partner_company_type_ids"] = self.get_company_types()

@mihien mihien force-pushed the 16.0-ref-cooperator-company_type branch 2 times, most recently from 3648c66 to ed5e7be Compare October 7, 2025 15:07
@mihien mihien force-pushed the 16.0-ref-cooperator-company_type branch 2 times, most recently from 20351b0 to b582938 Compare November 7, 2025 03:16
Copy link
Member

@huguesdk huguesdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few things to clean up, but apart from that, lgtm. thanks for this important (and tricky) improvement, @mihien!

Comment on lines 209 to 216
if not values.get("activities_country_id"):
if company.default_country_id:
values["activities_country_id"] = company.default_country_id.id
else:
values["activities_country_id"] = "20"
values["activities_country_id"] = 20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part is obsolete (i didn’t know about this field and it is used nowhere anymore) and can be removed.

@huguesdk huguesdk force-pushed the 16.0-ref-cooperator-company_type branch 2 times, most recently from 6dce7b0 to 70d41dc Compare November 10, 2025 16:26
Copy link
Member

@huguesdk huguesdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did the finishing touches myself so we can deploy. i added your changes to l10n_ch_cooperator here (after merging #146) and added a migration script.

i changed my mind about changes in readme files: pre-commit generates these changes anyway, so logically they should be added. but we need to ensure that the maintainer-tools repo used locally by pre-commit is up to date (and used with a recent python version), otherwise it could introduce changes that would be reverted after the merge.

@remytms remytms force-pushed the 16.0-ref-cooperator-company_type branch from 818bb8a to 11afe6a Compare December 15, 2025 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants