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

added fields #6

Closed

Conversation

zoro2002
Copy link

No description provided.

@zoro2002 zoro2002 marked this pull request as draft August 22, 2023 07:41
@ecino ecino marked this pull request as ready for review August 31, 2023 13:45
@@ -9,7 +9,7 @@
"license": "AGPL-3",
"website": "https://github.com/OCA/partner-contact",
"depends": ["base"],
"data": ["cron/update_cron.xml", "views/smart_tagger_view.xml"],
"data": ["cron/update_cron.xml", "views/smart_tagger_view.xml", "views/res_partner_category_view_extension.xml"],
Copy link
Member

Choose a reason for hiding this comment

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

You forgot to include file views/res_partner_category_view_extension.xml in your commit. But anyway, if you are modifying the view of res.partner.category object, you can directly do it in the same inheritance already existing in file views/smart_tagger_view.xml. No need to create multiple views for the same object inside the same module.

@@ -1,2 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import res_partner_category
from . import res_partner_category_extension
Copy link
Member

Choose a reason for hiding this comment

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

Again, no need to create a new class inheritance. The same class is already extendend in res_partner_category file, and you should put your additions inside it.

Comment on lines +7 to +9
author_of_the_tag = fields.Many2one('res.users', string="Author")
department_that_uses_the_tag = fields.Many2one('hr.department', string="Department")
description_of_the_tag = fields.Text(string="Description")
Copy link
Member

Choose a reason for hiding this comment

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

There are field naming conventions based upon their type. Especially for relational field, they should be suffixed by _id or _ids. I propose this:

Suggested change
author_of_the_tag = fields.Many2one('res.users', string="Author")
department_that_uses_the_tag = fields.Many2one('hr.department', string="Department")
description_of_the_tag = fields.Text(string="Description")
user_id = fields.Many2one('res.users', "Author", domain=[("share", "=", False)]) # domain is here to avoid putting external users
department_id = fields.Many2one('hr.department', "Department")
description = fields.Char() # We don't want a large description, char field should be enough.

author_of_the_tag = fields.Many2one('res.users', string="Author")
department_that_uses_the_tag = fields.Many2one('hr.department', string="Department")
description_of_the_tag = fields.Text(string="Description")
valid_until = fields.Date(string="Valid until")
Copy link
Member

Choose a reason for hiding this comment

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

No need to specify the string attribute if it's the same as the field name (_ is automatically replaced by spaces in the UI)

Suggested change
valid_until = fields.Date(string="Valid until")
valid_until = fields.Date()

Comment on lines +19 to +22
records_to_activate = self.search([('valid_until', '>', today), ('active', '=', False)])
records_to_activate.write({'active': True})


Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't mind activating records that are archived. If they are so, it's probably because of a manual action performed by someone, and we wouldn't want to change that automatically.

Suggested change
records_to_activate = self.search([('valid_until', '>', today), ('active', '=', False)])
records_to_activate.write({'active': True})

@ecino ecino closed this Nov 20, 2023
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