-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
[MIG]13.0 mig l10n_jp_partner_title_qweb #22
Conversation
There was a problem hiding this 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?
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".' | ||
) | ||
) |
There was a problem hiding this comment.
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.
# 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
3e92a20
to
d2ff774
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review. 👍
a3d2e29
to
7b2d49e
Compare
* [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
update translation update readme
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.
7b2d49e
to
79402c0
Compare
/ocabot merge nobump |
On my way to merge this fine PR! |
Congratulations, your PR was merged at 5d6f44a. Thanks a lot for contributing to OCA. ❤️ |
No description provided.