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

[MIG]13.0 mig l10n_jp_partner_title_qweb #22

Merged
merged 6 commits into from
Aug 7, 2022

Conversation

Ryoko04
Copy link
Contributor

@Ryoko04 Ryoko04 commented Sep 24, 2021

No description provided.

@Ryoko04 Ryoko04 marked this pull request as ready for review September 24, 2021 07:14
@Ryoko04 Ryoko04 marked this pull request as draft September 24, 2021 08:30
@Ryoko04 Ryoko04 marked this pull request as ready for review September 24, 2021 08:32
Copy link
Sponsor Member

@yostashiro yostashiro left a comment

Choose a reason for hiding this comment

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

@Ryoko04 I was thinking that we should remove the logic from this module as it causes issues in some cases (e.g. an 'individual' partner in Odoo could be an organization, etc.). We can simplify this module and let users update partners manually as needed instead of automatically proposing the titles. What do you think?

Comment on lines 14 to 45
lang_id = fields.Many2one(
"res.lang",
string="Language",
help="The Language for which this title should be proposed in partner "
"records.",
)
for_company = fields.Boolean(
"For Company",
help="If selected, this title should be proposed to company partners "
"according to the language selection of the partner.",
)

@api.constrains("lang_id", "for_company")
def _check_lang_id_for_company(self):
for record in self:
if (
record.lang_id
and self.search_count(
[
("lang_id", "=", record.lang_id.id),
("for_company", "=", record.for_company),
]
)
> 1
):
raise ValidationError(
_(
"You cannot have more than one record "
'for a combination of "Language" and '
'"For Company".'
)
)
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

We should probably remove this part.

Comment on lines 1 to 43
# Copyright 2018-2019 Quartile Limited
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import api, fields, models


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

# we make title a computed field instead of using onchange to update it
# because onchange is not triggered when a user signs up from portal
title = fields.Many2one(compute="_compute_title", store=True, readonly=False,)

@api.depends("lang", "is_company")
def _compute_title(self):
for partner in self:
# handle the case NewId is returned for partner.id (i.e. onchange)
partner_id = (
self._origin.id if isinstance(partner.id, models.NewId) else partner.id
)
# no title proposal for partners linked to internal users and
# companies (res.company)
if (
not partner.lang
or partner.user_ids
and not partner.user_ids.share
or self.env["res.company"].search([("partner_id", "=", partner_id)])
):
partner.title = False
else:
lang_id = (
self.env["res.lang"]
.search([("code", "=", partner.lang)], limit=1)
.id
)
title = self.env["res.partner.title"].search(
[
("lang_id", "=", lang_id),
("for_company", "=", partner.is_company),
],
limit=1,
)
partner.title = title.id if title else False
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

We should probably remove this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your review. I agree with you. I will update them.

@Ryoko04 Ryoko04 force-pushed the 13.0-mig-l10n_jp_partner_title_qweb branch from 3e92a20 to d2ff774 Compare October 1, 2021 14:03
Copy link
Sponsor Member

@yostashiro yostashiro left a comment

Choose a reason for hiding this comment

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

Code review. 👍

@yostashiro yostashiro force-pushed the 13.0-mig-l10n_jp_partner_title_qweb branch 2 times, most recently from a3d2e29 to 7b2d49e Compare August 7, 2022 07:41
yostashiro and others added 6 commits August 7, 2022 16:05
* [ADD] l10n_jp_partner_title_qweb

* minor adjustments

* remove blank line

* [FIX] wrong object reference

* remove onchu translation

* [IMP] add constraint

* show title field

* [FIX] version

* add tests

* [FIX] enable japanese
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: l10n-japan-12.0/l10n-japan-12.0-l10n_jp_partner_title_qweb
Translate-URL: https://translation.odoo-community.org/projects/l10n-japan-12-0/l10n-japan-12-0-l10n_jp_partner_title_qweb/
Remove the tile proposal logic of res.partner to avoid the complexity - in some cases
an 'individual' partner in Odoo could be an organization, etc., and we conclude that
we should not have a rigid proposal logic in this module.
@yostashiro yostashiro force-pushed the 13.0-mig-l10n_jp_partner_title_qweb branch from 7b2d49e to 79402c0 Compare August 7, 2022 08:06
@yostashiro
Copy link
Sponsor Member

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 13.0-ocabot-merge-pr-22-by-yostashiro-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit e63fa88 into OCA:13.0 Aug 7, 2022
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 5d6f44a. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants