forked from OCA/partner-contact
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
<odoo> | ||
<record id="smart_tags_updater" model="ir.cron"> | ||
<field name="name">Smart Tags Updater</field> | ||
<field name="active" eval="True" /> | ||
<field name="user_id" ref="base.user_root" /> | ||
<field name="active" eval="True"/> | ||
<field name="user_id" ref="base.user_root"/> | ||
<field name="interval_number">1</field> | ||
<field name="interval_type">weeks</field> | ||
<field name="numbercall">-1</field> | ||
<field name="doall">1</field> | ||
<field name="model_id" ref="model_res_partner_category" /> | ||
<field name="model_id" ref="model_res_partner_category"/> | ||
<field name="state">code</field> | ||
<field name="code">model.update_all_smart_tags()</field> | ||
</record> | ||
|
||
<record id="ir_cron_check_validity_dates" model="ir.cron"> | ||
<field name="name">Check Validity Dates</field> | ||
<field name="active" eval="True"/> | ||
<field name="user_id" ref="base.user_root"/> | ||
<field name="interval_number">1</field> | ||
<field name="interval_type">days</field> | ||
<field name="numbercall">-1</field> | ||
<field name="model_id" ref="model_res_partner_category"/> | ||
<field name="state">code</field> | ||
<field name="code">model._check_validity_dates()</field> | ||
</record> | ||
</odoo> |
20 changes: 16 additions & 4 deletions
20
partner_tag_smart_assignation/models/res_partner_category_extension.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
from odoo import fields, models | ||
from odoo import fields, models, api | ||
|
||
|
||
class ResPartnerCategoryExtension(models.Model): | ||
_inherit = "res.partner.category" | ||
|
||
author_of_the_tag = fields.Char(string="Author") | ||
department_that_uses_the_tag = fields.Char(string="Department") | ||
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") | ||
is_unlimited_tag = fields.Boolean(string="Unlimited") | ||
valid_until = fields.Date(string="Valid until") | ||
|
||
@api.model | ||
def _check_validity_dates(self): | ||
""" Scheduled method to deactivate records past their validity date """ | ||
today = fields.Date.today() | ||
records_to_deactivate = self.search([('valid_until', '<', today), ('active', '=', True)]) | ||
records_to_deactivate.write({'active': False}) | ||
|
||
records_to_activate = self.search([('valid_until', '>', today), ('active', '=', False)]) | ||
records_to_activate.write({'active': True}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters