|
@ -1,4 +1,5 @@ |
|
|
from odoo import models, fields, api |
|
|
|
|
|
|
|
|
from odoo import models, fields, api, _ |
|
|
|
|
|
from odoo.osv.expression import normalize_domain, AND |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ResPartner(models.Model): |
|
|
class ResPartner(models.Model): |
|
@ -48,7 +49,38 @@ class ResPartner(models.Model): |
|
|
else: |
|
|
else: |
|
|
survey.sent_comp_ratio = int(round(100 * survey.tot_sent_comp_survey / survey.tot_sent_survey, 0)) |
|
|
survey.sent_comp_ratio = int(round(100 * survey.tot_sent_comp_survey / survey.tot_sent_survey, 0)) |
|
|
|
|
|
|
|
|
|
|
|
# ACTIONS |
|
|
|
|
|
|
|
|
|
|
|
@api.multi |
|
|
|
|
|
def action_survey_user_input(self): |
|
|
|
|
|
self.ensure_one() |
|
|
|
|
|
action = self.env.ref('survey.action_survey_user_input').read()[0] |
|
|
|
|
|
action['display_name'] += _(" from {}").format(self.display_name) |
|
|
|
|
|
# manage context |
|
|
|
|
|
ctx = dict(self.env.context) |
|
|
|
|
|
link_only = ctx.pop('link_only', False) |
|
|
|
|
|
action['context'] = ctx |
|
|
|
|
|
# manage domain |
|
|
|
|
|
domain = action.get('domain') or [] |
|
|
|
|
|
if isinstance(domain, str): |
|
|
|
|
|
domain = eval(domain) |
|
|
|
|
|
if len(domain) > 1: |
|
|
|
|
|
domain = AND([['|', ('partner_id', '=', self.id), ('email', 'ilike', self.email)], normalize_domain(domain)]) |
|
|
|
|
|
else: |
|
|
|
|
|
domain = ['|', ('partner_id', '=', self.id), ('email', 'ilike', self.email)] |
|
|
|
|
|
if link_only: |
|
|
|
|
|
if len(domain) > 1: |
|
|
|
|
|
domain = AND([[('type', '=', 'link')], normalize_domain(domain)]) |
|
|
|
|
|
else: |
|
|
|
|
|
domain = [('type', '=', 'link')] |
|
|
|
|
|
action['domain'] = domain |
|
|
|
|
|
# return updated action |
|
|
|
|
|
return action |
|
|
|
|
|
|
|
|
|
|
|
# ONCHANGES |
|
|
|
|
|
|
|
|
@api.onchange('email') |
|
|
@api.onchange('email') |
|
|
def onchange_email(self): |
|
|
def onchange_email(self): |
|
|
|
|
|
self.ensure_one() |
|
|
if isinstance(self._origin.id, int): |
|
|
if isinstance(self._origin.id, int): |
|
|
self._count_survey_input() |
|
|
self._count_survey_input() |