Browse Source

Added filter by Partner

pull/1/head
Veronika Kotovich 9 years ago
parent
commit
6f2681f616
  1. 5
      i18n/mail_move_message.pot
  2. 16
      mail_move_message_models.py
  3. 5
      mail_move_message_views.xml

5
i18n/mail_move_message.pot

@ -161,3 +161,8 @@ msgstr ""
#: help:mail_move_message.wizard,model_id:0 #: help:mail_move_message.wizard,model_id:0
msgid "List available Models is configured at Settings\Technical\Emails\Mail Relocation. Empty for unassigned email" msgid "List available Models is configured at Settings\Technical\Emails\Mail Relocation. Empty for unassigned email"
msgstr "" msgstr ""
#. module: mail_move_message
#: help:mail_move_message.wizard,filter_by_partner:0
msgid "Show only records with the same partner as email author"
msgstr ""

16
mail_move_message_models.py

@ -16,6 +16,8 @@ class wizard(models.TransientModel):
can_move = fields.Boolean('Can move', compute='get_can_move') can_move = fields.Boolean('Can move', compute='get_can_move')
move_back = fields.Boolean('Move to origin', help='Move message and submessages to original place') move_back = fields.Boolean('Move to origin', help='Move message and submessages to original place')
model = fields.Char('Model', related='model_id.model') model = fields.Char('Model', related='model_id.model')
partner_id = fields.Many2one('res.partner', string='Author')
filter_by_partner = fields.Boolean('Filter Records by partner')
@api.depends('message_id') @api.depends('message_id')
@api.one @api.one
@ -57,6 +59,20 @@ class wizard(models.TransientModel):
self.record_url = '/web#id=%s&model=%s' % (self.res_id, self.model_id.model) self.record_url = '/web#id=%s&model=%s' % (self.res_id, self.model_id.model)
@api.onchange('filter_by_partner', 'partner_id')
def on_change_partner(self):
domain = {'res_id': []}
if self.filter_by_partner and self.partner_id:
fields = self.env[self.model].fields_get(False)
contact_field = False
for n, f in fields.iteritems():
if f['type'] == 'many2one' and f['relation'] == 'res.partner':
contact_field = n
break
if contact_field:
domain['res_id'] = [(contact_field, '=', self.partner_id.id)]
return {'domain': domain}
@api.one @api.one
def check_access(self): def check_access(self):
cr = self._cr cr = self._cr

5
mail_move_message_views.xml

@ -25,8 +25,9 @@
</group> </group>
<group attrs="{'invisible':[('can_move', '=', False)]}" col="4"> <group attrs="{'invisible':[('can_move', '=', False)]}" col="4">
<field name="move_back" attrs="{'invisible':[('message_is_moved','=',False)]}" colspan="4"/> <field name="move_back" attrs="{'invisible':[('message_is_moved','=',False)]}" colspan="4"/>
<field name="parent_id" domain="[('parent_id','=', False)]" context="{'extended_name':1}" colspan="4"/>
<field name="model_id" colspan="2"/>
<field name="model_id" class="oe_inline"/>
<field name="filter_by_partner"/>
<field name="partner_id"/>
<field name="res_id" colspan="2" context="{'extended_name_with_contact':1}"/> <field name="res_id" colspan="2" context="{'extended_name_with_contact':1}"/>
<field name="record_url" colspan="4" widget="url"/> <field name="record_url" colspan="4" widget="url"/>
</group> </group>

Loading…
Cancel
Save