Browse Source

[ADD] missing action in survey_partner_input

12.0
Rémi FRANÇOIS 5 years ago
parent
commit
c5b466898c
  1. 1
      survey_partner_input/__manifest__.py
  2. 34
      survey_partner_input/models/res_partner.py
  3. 4
      survey_partner_input/views/res_partner.xml
  4. 16
      survey_partner_input/views/survey_user_input.xml

1
survey_partner_input/__manifest__.py

@ -16,6 +16,7 @@
],
'data': [
'views/res_partner.xml',
'views/survey_user_input.xml',
],
'demo': [],
'auto_install': False,

34
survey_partner_input/models/res_partner.py

@ -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):
@ -48,7 +49,38 @@ class ResPartner(models.Model):
else:
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')
def onchange_email(self):
self.ensure_one()
if isinstance(self._origin.id, int):
self._count_survey_input()

4
survey_partner_input/views/res_partner.xml

@ -9,12 +9,12 @@
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']/button[1]" position="before">
<button type="object" name="action_survey_user_input"
context="{'search_default_completed':1, 'link_only':1, 'search_default_partner_id': id}"
context="{'link_only':1, 'search_default_by_state':1}"
attrs="{'invisible':[('tot_sent_survey','=',0)]}" class="oe_stat_button">
<field string="Completed" name="sent_comp_ratio" widget="percentpie"/>
</button>
<button type="object" name="action_survey_user_input" class="oe_stat_button" icon="fa-pencil-square-o"
context="{'search_default_completed':1, 'link_only':1, 'search_default_partner_id': id}"
context="{'search_default_completed':1, 'search_default_group_by_survey':1}"
attrs="{'invisible':[('tot_sent_survey','=',0),('tot_comp_survey','=',0)]}">
<field string="Answers" name="tot_comp_survey" widget="statinfo"/>
</button>

16
survey_partner_input/views/survey_user_input.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="survey_user_input_search" model="ir.ui.view">
<field name="name">survey_select_input survey.user_input search</field>
<field name="model">survey.user_input</field>
<field name="inherit_id" ref="survey.survey_user_input_search"/>
<field name="priority">26</field>
<field name="arch" type="xml">
<filter name="group_by_partner" position="after">
<filter name="by_state" string="État" domain="[]" context="{'group_by': 'state'}"/>
</filter>
</field>
</record>
</odoo>
Loading…
Cancel
Save