Skip to content
Extraits de code Groupes Projets
Valider cae334e9 rédigé par jordan's avatar jordan
Parcourir les fichiers

[update] conf for email with compute recipients

parent fb34ff11
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -13,3 +13,8 @@ class ScopCotisationCompany(models.Model):
string='Journal des cotisations',
domain="[('type', '=', 'sale')]"
)
tag_id = fields.Many2one(
comodel_name='res.partner.category',
string='Etiquette de cotisation',
ondelete='restrict'
)
......@@ -18,6 +18,15 @@ class CotisationsConfigSettings(models.TransientModel):
string='Journal des cotisations',
domain="[('type', '=', 'sale')]")
tag_id = fields.Many2one(
comodel_name='res.partner.category',
related="company_id.tag_id",
readonly=False,
string='Etiquette de cotisation')
# ------------------------------------------------------
# Actions
# ------------------------------------------------------
def add_company_to_menu(self, menu, bool_condition):
"""
Add current company to the list of companies allowed to see menu
......@@ -37,6 +46,9 @@ class CotisationsConfigSettings(models.TransientModel):
"company_ids": [(3, current_company_id.id)]
})
# ------------------------------------------------------
# Override Parent
# ------------------------------------------------------
def execute(self):
"""
Rewrite execute() function to add current company to the list
......
......@@ -41,6 +41,17 @@ class ScopCotisation(models.AbstractModel):
"Cotisations créées",
compute='_compute_invoiced_member_count')
# Emails management
recipient_ids = fields.One2many(
comodel_name='res.partner',
compute='_compute_recipient'
)
# TODO : Use when email active
# email_count = fields.Integer(
# string='Nombre de mails',
# compute='_compute_emails'
# )
# ------------------------------------------------------
# Compute fields
# ------------------------------------------------------
......@@ -60,6 +71,18 @@ class ScopCotisation(models.AbstractModel):
cotiz.invoiced_member_count = len(
cotiz.invoice_ids.mapped('partner_id'))
@api.multi
def _compute_recipient(self):
tag_id = self.env.user.company_id.tag_id
for cotiz in self:
child_ids = cotiz.partner_id.child_ids.filtered(
lambda child: (tag_id in child.category_id) and child.email
)
if cotiz.partner_id.email:
cotiz.recipient_ids = cotiz.partner_id + child_ids
else:
cotiz.recipient_ids = child_ids
# ------------------------------------------------------
# Global functions
# ------------------------------------------------------
......@@ -118,3 +141,8 @@ class ScopCotisation(models.AbstractModel):
('end', '>', date(self.year, 1, 1))
]).mapped('partner_id')
return members
# TODO : Use when email active
# Email
# def get_recipients(self):
# return ','.join(map(lambda x: str(x), self.recipient_ids.ids))
......@@ -29,6 +29,14 @@
</div>
<field name="contribution_journal_id" options="{'no_open': True, 'no_create': True}"/>
</div>
<div class="o_setting_left_pane"/>
<div class="o_setting_right_pane">
<label for="tag_id"/>
<div class="text-muted">
Etiquette associée aux contacts cotisations
</div>
<field name="tag_id" options="{'no_open': True, 'no_create': True}"/>
</div>
</div>
</div>
</xpath>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter