Skip to content

Commit 5d9efe5

Browse files
committed
[IMP] coop_mass_mailing_contact: pre-commit auto fixes
1 parent 3144374 commit 5d9efe5

7 files changed

Lines changed: 53 additions & 56 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from . import models
1+
from . import models

coop_mass_mailing_contact/__manifest__.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55

66

77
{
8-
'name': 'Mass Mailing - Contact',
9-
'version': '12.0.1.0.0',
10-
'category': 'Tools',
11-
'summary': "Create the contact for each member",
12-
'author': 'Trobz',
13-
'website': 'https://www.trobz.com',
14-
'depends': [
15-
'coop_membership',
8+
"name": "Mass Mailing - Contact",
9+
"version": "12.0.1.0.0",
10+
"category": "Tools",
11+
"summary": "Create the contact for each member",
12+
"author": "Trobz",
13+
"website": "https://github.com/AwesomeFoodCoops/odoo-production",
14+
"depends": [
15+
"coop_membership",
1616
],
17-
'data': [
17+
"data": [
1818
"data/ir_cron.xml",
1919
"views/view_mail_mass_mailing.xml",
2020
],
21-
'license': 'AGPL-3',
22-
'installable': True,
21+
"license": "AGPL-3",
22+
"installable": True,
2323
}
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0" ?>
22
<odoo>
33
<data noupdate="1">
44
<record model="ir.cron" id="cron_compute_contact">
55
<field name="name">Mailing List: Add the contact from member</field>
66
<field name="interval_number">1</field>
77
<field name="interval_type">days</field>
88
<field name="numbercall">-1</field>
9-
<field name="doall" eval="False"/>
10-
<field name="model_id" ref="coop_mass_mailing_contact.model_mail_mass_mailing_list"/>
9+
<field name="doall" eval="False" />
10+
<field
11+
name="model_id"
12+
ref="coop_mass_mailing_contact.model_mail_mass_mailing_list"
13+
/>
1114
<field name="code">model.cron_compute_contact()</field>
1215
<field name="state">code</field>
13-
<field name="nextcall" eval="DateTime.now().strftime('%Y-%m-%d 20:00:00')"/>
16+
<field
17+
name="nextcall"
18+
eval="DateTime.now().strftime('%Y-%m-%d 20:00:00')"
19+
/>
1420
</record>
15-
1621
</data>
1722
</odoo>
Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
# -*- coding: utf-8 -*-
2-
31
from odoo import api, fields, models
42

53

64
class MassMailingList(models.Model):
7-
_inherit = 'mail.mass_mailing.list'
5+
_inherit = "mail.mass_mailing.list"
86

97
is_member_contact = fields.Boolean(
10-
default=False,
11-
help="Populate the contact from the members")
8+
default=False, help="Populate the contact from the members"
9+
)
1210

1311
def compute_contacts(self, limit=1000):
1412
self.remove_contacts()
@@ -17,7 +15,7 @@ def compute_contacts(self, limit=1000):
1715
def remove_contacts(self):
1816
if not self:
1917
return
20-
sql = """
18+
sql = f"""
2119
DELETE FROM mail_mass_mailing_contact_list_rel
2220
WHERE id IN (
2321
SELECT ctr.id
@@ -31,17 +29,15 @@ def remove_contacts(self):
3129
) rp
3230
ON rp.email = ct.email
3331
WHERE rp.is_member IS FALSE
34-
AND ctr.list_id in {ctr_ids}
35-
)
36-
""".format(
37-
ctr_ids=str(tuple(self.ids + [-1]))
32+
AND ctr.list_id in {str(tuple(self.ids + [-1]))}
3833
)
34+
"""
3935
self._cr.execute(sql)
4036

4137
def add_contacts(self, limit=1000):
4238
if not self:
4339
return
44-
sql = """
40+
sql = f"""
4541
SELECT rp.id, rp.name, rp.email, rp.opt_out
4642
FROM res_partner rp
4743
LEFT JOIN mail_mass_mailing_contact ct
@@ -50,24 +46,21 @@ def add_contacts(self, limit=1000):
5046
AND rp.email NOTNULL
5147
AND rp.is_member IS TRUE
5248
LIMIT {limit}
53-
""".format(
54-
limit=limit
55-
)
49+
"""
5650
self._cr.execute(sql)
5751
datas = self._cr.fetchall()
5852
for data in datas:
5953
vals = {
60-
'name': data[1],
61-
'email': data[2],
62-
'is_member_contact': True,
63-
'subscription_list_ids': []
54+
"name": data[1],
55+
"email": data[2],
56+
"is_member_contact": True,
57+
"subscription_list_ids": [],
6458
}
6559
for list in self:
66-
vals['subscription_list_ids'].append((0, 0, {
67-
'list_id': list.id,
68-
'opt_out': data[3]
69-
}))
70-
contact = self.env['mail.mass_mailing.contact'].create(vals)
60+
vals["subscription_list_ids"].append(
61+
(0, 0, {"list_id": list.id, "opt_out": data[3]})
62+
)
63+
contact = self.env["mail.mass_mailing.contact"].create(vals)
7164

7265
@api.model
7366
def cron_compute_contact(self, limit=1000):
@@ -76,7 +69,5 @@ def cron_compute_contact(self, limit=1000):
7669
- Remove the contact which not the member anymore
7770
- Create new contact for a new member
7871
"""
79-
list = self.search([
80-
('is_member_contact', '=', True)
81-
])
72+
list = self.search([("is_member_contact", "=", True)])
8273
list.compute_contacts(limit)
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
# -*- coding: utf-8 -*-
2-
3-
from odoo import api, fields, models
1+
from odoo import fields, models
42

53

64
class MassMailingContact(models.Model):
7-
_inherit = 'mail.mass_mailing.contact'
5+
_inherit = "mail.mass_mailing.contact"
86

9-
is_member_contact = fields.Boolean(
10-
default=False)
7+
is_member_contact = fields.Boolean(default=False)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"

coop_mass_mailing_contact/views/view_mail_mass_mailing.xml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0" ?>
22
<!--
33
Copyright (C) 2016-Today: La Louve (<http://www.lalouve.net/>)
44
Copyright (C) 2019-Today: Druidoo (<https://www.druidoo.io>)
55
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
66
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
77
-->
8-
98
<odoo>
10-
119
<record id="view_mail_mass_mailing_list_form_inherit" model="ir.ui.view">
1210
<field name="model">mail.mass_mailing.list</field>
13-
<field name="inherit_id" ref="mass_mailing.view_mail_mass_mailing_list_form"/>
11+
<field name="inherit_id" ref="mass_mailing.view_mail_mass_mailing_list_form" />
1412
<field name="arch" type="xml">
1513
<field name="is_public" position="after">
16-
<field name="is_member_contact"/>
14+
<field name="is_member_contact" />
1715
</field>
1816
</field>
1917
</record>
2018
<record id="view_mail_mass_mailing_list_form_simplified_inherit" model="ir.ui.view">
2119
<field name="model">mail.mass_mailing.list</field>
22-
<field name="inherit_id" ref="mass_mailing.view_mail_mass_mailing_list_form_simplified"/>
20+
<field
21+
name="inherit_id"
22+
ref="mass_mailing.view_mail_mass_mailing_list_form_simplified"
23+
/>
2324
<field name="arch" type="xml">
2425
<field name="is_public" position="after">
25-
<field name="is_member_contact"/>
26+
<field name="is_member_contact" />
2627
</field>
2728
</field>
2829
</record>

0 commit comments

Comments
 (0)