Code refactorings
This commit is contained in:
parent
2c1a03a1b4
commit
770f10896e
@ -27,5 +27,7 @@
|
|||||||
'application': True,
|
'application': True,
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'depends': ['golem_member'],
|
'depends': ['golem_member'],
|
||||||
'data': ['views/golem_mail_member_views.xml']
|
'data': ['views/golem_mail_member_views.xml',
|
||||||
|
'views/golem_mail_res_partner_views.xml',
|
||||||
|
'data/res_partner_data.xml']
|
||||||
}
|
}
|
||||||
|
27
golem_mail_member/data/res_partner_data.xml
Normal file
27
golem_mail_member/data/res_partner_data.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<odoo>
|
||||||
|
<data noupdate="1">
|
||||||
|
|
||||||
|
<!-- Base Accounting settings call -->
|
||||||
|
<function model="golem.res.partner.config" name="res_partner_settings" />
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</odoo>
|
@ -16,4 +16,4 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from . import golem_member
|
from . import golem_member, golem_res_partner_config
|
||||||
|
@ -42,3 +42,26 @@ class GolemMember(models.Model):
|
|||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
'target': 'new'
|
'target': 'new'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ResPartner(models.Model):
|
||||||
|
""" Res Partner adaptations """
|
||||||
|
_inherit = 'res.partner'
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def get_mass_mailing_action(self):
|
||||||
|
""" Call res partner mass mailing presend wizard """
|
||||||
|
partners = self.ids
|
||||||
|
presend_wizard = self.env['golem.mail.presend.wizard'].create(
|
||||||
|
{'partner_ids': [(6, 0, partners)]})
|
||||||
|
for partner in partners:
|
||||||
|
self.env['golem.mail.recipient'].create({'partner_id': partner,
|
||||||
|
'presend_wizard_id': presend_wizard.id})
|
||||||
|
return {
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'name': 'Member mass mailing',
|
||||||
|
'res_model': 'golem.mail.presend.wizard',
|
||||||
|
'res_id': presend_wizard.id,
|
||||||
|
'view_mode': 'form',
|
||||||
|
'view_type': 'form',
|
||||||
|
'target': 'new'
|
||||||
|
}
|
||||||
|
32
golem_mail_member/models/golem_res_partner_config.py
Normal file
32
golem_mail_member/models/golem_res_partner_config.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
""" GOLEM Res Partner Configuration """
|
||||||
|
|
||||||
|
from odoo import models, api, _
|
||||||
|
|
||||||
|
|
||||||
|
class ResPartnerConfig(models.AbstractModel):
|
||||||
|
""" GOLEM Res Partner Configuration """
|
||||||
|
_name = 'golem.res.partner.config'
|
||||||
|
_description = 'GOLEM Res Partner Configuration'
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def res_partner_settings(self):
|
||||||
|
""" Res partner mas mailing remove """
|
||||||
|
if self.env.ref('base.action_partner_mass_mail'):
|
||||||
|
self.env.ref('base.action_partner_mass_mail').unlink()
|
38
golem_mail_member/views/golem_mail_res_partner_views.xml
Normal file
38
golem_mail_member/views/golem_mail_res_partner_views.xml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
|
||||||
|
Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<!-- Add action to members list-->
|
||||||
|
<record id="action_golem_res_partner_mass_mailing" model="ir.actions.server">
|
||||||
|
<field name="name">Partner mass mailing</field>
|
||||||
|
<field name="model_id" ref="base.model_res_partner"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">
|
||||||
|
action = records.get_mass_mailing_action()
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<record id="ir_golem_res_partner_mass_mailing" model="ir.values">
|
||||||
|
<field name="key2" eval="'client_action_multi'" />
|
||||||
|
<field name="model" eval="'res.partner'" />
|
||||||
|
<field name="name">Partner mass mailing</field>
|
||||||
|
<field name="value"
|
||||||
|
eval="'ir.actions.server,%d'%action_golem_res_partner_mass_mailing" />
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
Loading…
Reference in New Issue
Block a user