Browse Source

Merge pull request #196 from Tecnativa/10.0-fix-mass_mailing_partner_permission

[FIX] mass_mailing_partner: permissions
pull/198/head
Pedro M. Baeza 7 years ago
committed by GitHub
parent
commit
839575f573
  1. 2
      mass_mailing_partner/__manifest__.py
  2. 5
      mass_mailing_partner/models/res_partner.py
  3. 2
      mass_mailing_partner/views/res_partner_view.xml

2
mass_mailing_partner/__manifest__.py

@ -7,7 +7,7 @@
{ {
"name": "Link partners with mass-mailing", "name": "Link partners with mass-mailing",
"version": "10.0.1.0.0",
"version": "10.0.1.0.1",
"author": "Tecnativa, " "author": "Tecnativa, "
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
"website": "https://www.tecnativa.com", "website": "https://www.tecnativa.com",

5
mass_mailing_partner/models/res_partner.py

@ -19,7 +19,8 @@ class ResPartner(models.Model):
comodel_name='mail.mass_mailing.contact', inverse_name='partner_id') comodel_name='mail.mass_mailing.contact', inverse_name='partner_id')
mass_mailing_contacts_count = fields.Integer( mass_mailing_contacts_count = fields.Integer(
string='Mailing list number', string='Mailing list number',
compute='_compute_mass_mailing_contacts_count', store=True)
compute='_compute_mass_mailing_contacts_count', store=True,
compute_sudo=True)
mass_mailing_stats = fields.One2many( mass_mailing_stats = fields.One2many(
string="Mass mailing stats", string="Mass mailing stats",
comodel_name='mail.mail.statistics', inverse_name='partner_id') comodel_name='mail.mail.statistics', inverse_name='partner_id')
@ -30,7 +31,7 @@ class ResPartner(models.Model):
@api.constrains('email') @api.constrains('email')
def _check_email_mass_mailing_contacts(self): def _check_email_mass_mailing_contacts(self):
for partner in self: for partner in self:
if partner.mass_mailing_contact_ids and not partner.email:
if partner.sudo().mass_mailing_contact_ids and not partner.email:
raise ValidationError( raise ValidationError(
_("This partner '%s' is subscribed to one or more " _("This partner '%s' is subscribed to one or more "
"mailing lists. Email must be assigned.") % partner.name) "mailing lists. Email must be assigned.") % partner.name)

2
mass_mailing_partner/views/res_partner_view.xml

@ -10,6 +10,7 @@
<field name="name">Partner Form with mailing contacts</field> <field name="name">Partner Form with mailing contacts</field>
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/> <field name="inherit_id" ref="base.view_partner_form"/>
<field name="groups_id" eval="[(4, ref('mass_mailing.group_mass_mailing_user'))]"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<div name="button_box" position="inside"> <div name="button_box" position="inside">
<button name="%(mass_mailing.action_view_mass_mailing_contacts)d" <button name="%(mass_mailing.action_view_mass_mailing_contacts)d"
@ -40,6 +41,7 @@
<field name="name">Partner Search with mailing contacts</field> <field name="name">Partner Search with mailing contacts</field>
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter"/> <field name="inherit_id" ref="base.view_res_partner_filter"/>
<field name="groups_id" eval="[(4, ref('mass_mailing.group_mass_mailing_user'))]"/>
<field name="priority">20</field> <field name="priority">20</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="category_id" position="after"> <field name="category_id" position="after">

Loading…
Cancel
Save