Browse Source

[IMP] Allow to have different mail template per share.

This allows to have different mail for "payment received confirmation".
The mail template can be defined on the share type form. Then on
reconciliation process, if a specific mail template has been defined it
will override the default one. otherwise the default mail template will
be used.
pull/1/head
houssine 6 years ago
parent
commit
269ab82522
  1. 5
      easy_my_coop/models/account_invoice.py
  2. 14
      easy_my_coop/models/product.py
  3. 1
      easy_my_coop/view/product_view.xml

5
easy_my_coop/models/account_invoice.py

@ -59,6 +59,8 @@ class account_invoice(models.Model):
sequence_operation = self.env.ref('easy_my_coop.sequence_register_operation', False) sequence_operation = self.env.ref('easy_my_coop.sequence_register_operation', False)
sub_reg_operation = sequence_operation.next_by_id() sub_reg_operation = sequence_operation.next_by_id()
certificat_email_template = self.env.ref(mail_template_id, False)
for line in self.invoice_line_ids: for line in self.invoice_line_ids:
self.env['subscription.register'].create({ self.env['subscription.register'].create({
'name': sub_reg_operation, 'name': sub_reg_operation,
@ -77,8 +79,9 @@ class account_invoice(models.Model):
'share_unit_price': line.price_unit, 'share_unit_price': line.price_unit,
'effective_date': effective_date 'effective_date': effective_date
}) })
if line.product_id.mail_template:
certificat_email_template = line.product_id.mail_template
certificat_email_template = self.env.ref(mail_template_id, False)
# we send the email with the certificat in attachment # we send the email with the certificat in attachment
certificat_email_template.send_mail(self.partner_id.id, False) certificat_email_template.send_mail(self.partner_id.id, False)

14
easy_my_coop/models/product.py

@ -5,15 +5,17 @@ from openerp import api, fields, models
class ProductTemplate(models.Model): class ProductTemplate(models.Model):
_inherit = 'product.template' _inherit = 'product.template'
is_share = fields.Boolean(string='Is share?')
short_name = fields.Char(string='Short name')
display_on_website = fields.Boolean(string='Display on website')
default_share_product = fields.Boolean(string='Default share product')
minimum_quantity = fields.Integer(string='Minimum quantity', default=1)
is_share = fields.Boolean(string="Is share?")
short_name = fields.Char(string="Short name")
display_on_website = fields.Boolean(string="Display on website")
default_share_product = fields.Boolean(string="Default share product")
minimum_quantity = fields.Integer(string="Minimum quantity", default=1)
force_min_qty = fields.Boolean(String="Force minimum quantity?") force_min_qty = fields.Boolean(String="Force minimum quantity?")
by_company = fields.Boolean(string="Can be subscribed by companies?") by_company = fields.Boolean(string="Can be subscribed by companies?")
by_individual = fields.Boolean(string="Can be subscribed by individuals?") by_individual = fields.Boolean(string="Can be subscribed by individuals?")
customer = fields.Boolean(string='Become customer')
customer = fields.Boolean(string="Become customer")
mail_template = fields.Many2one('mail.template',
string="Mail template")
@api.multi @api.multi
def get_web_share_products(self, is_company): def get_web_share_products(self, is_company):

1
easy_my_coop/view/product_view.xml

@ -31,6 +31,7 @@
<field name="customer" attrs="{'invisible':[('is_share','=',False)]}"/> <field name="customer" attrs="{'invisible':[('is_share','=',False)]}"/>
<field name="by_company" attrs="{'invisible':[('is_share','=',False)]}" groups="easy_my_coop.group_energiris_user"/> <field name="by_company" attrs="{'invisible':[('is_share','=',False)]}" groups="easy_my_coop.group_energiris_user"/>
<field name="by_individual" attrs="{'invisible':[('is_share','=',False)]}" groups="easy_my_coop.group_energiris_user"/> <field name="by_individual" attrs="{'invisible':[('is_share','=',False)]}" groups="easy_my_coop.group_energiris_user"/>
<field name="mail_template" attrs="{'invisible':[('is_share','=',False)]}" groups="easy_my_coop.group_energiris_user"/>
</xpath> </xpath>
</field> </field>
</record> </record>

Loading…
Cancel
Save