add get_opportunities
This commit is contained in:
parent
68e08393e5
commit
eae84422d3
|
@ -7,6 +7,7 @@ from .opportunity import *
|
|||
def register():
|
||||
Pool.register(
|
||||
Relation,
|
||||
PartyCampaign,
|
||||
CreateCampaignStart,
|
||||
module='sale_opportunity_campaign_contact', type_='model')
|
||||
Pool.register(
|
||||
|
|
116
locale/ca_ES.po
116
locale/ca_ES.po
|
@ -2,14 +2,108 @@
|
|||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.relation.type,available_on_campaign:"
|
||||
msgid "Available on campaing"
|
||||
msgstr "Disponible en campanyes"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,campaing:"
|
||||
msgid "Campaign"
|
||||
msgstr "Campanya"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,create_date:"
|
||||
msgid "Create Date"
|
||||
msgstr "Data de creació"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,create_uid:"
|
||||
msgid "Create User"
|
||||
msgstr "Usuari de creació"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,id:"
|
||||
msgid "ID"
|
||||
msgstr "Identificador"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,party:"
|
||||
msgid "Party"
|
||||
msgstr "Tercer"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,rec_name:"
|
||||
msgid "Name"
|
||||
msgstr "Nom"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,write_date:"
|
||||
msgid "Write Date"
|
||||
msgstr "Data modificació"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,write_uid:"
|
||||
msgid "Write User"
|
||||
msgstr "Usuari modificació"
|
||||
|
||||
msgctxt "field:party.relation.type,available_on_campaign:"
|
||||
msgid "Available on campaing"
|
||||
msgstr "Disponible en campanyes"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,campaing:"
|
||||
msgid "Campaign"
|
||||
msgstr "Campanya"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,create_date:"
|
||||
msgid "Create Date"
|
||||
msgstr "Data de creació"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,create_uid:"
|
||||
msgid "Create User"
|
||||
msgstr "Usuari de creació"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,id:"
|
||||
msgid "ID"
|
||||
msgstr "Identificador"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,party:"
|
||||
msgid "Party"
|
||||
msgstr "Tercer"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,rec_name:"
|
||||
msgid "Name"
|
||||
msgstr "Nom"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,write_date:"
|
||||
msgid "Write Date"
|
||||
msgstr "Data modificació"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,write_uid:"
|
||||
msgid "Write User"
|
||||
msgstr "Usuari modificació"
|
||||
|
||||
msgctxt "field:sale.opportunity.create_campaign.start,all_contacts:"
|
||||
msgid "All Contacts"
|
||||
msgstr "Tots els contactes"
|
||||
|
||||
msgctxt "field:sale.opportunity.create_campaign.start,create_leads:"
|
||||
msgid "Create Leads"
|
||||
msgstr "Crear iniciatives"
|
||||
|
||||
msgctxt "field:sale.opportunity.create_campaign.start,create_leads:"
|
||||
msgid "Create Leads"
|
||||
msgstr "Crear iniciatives"
|
||||
|
||||
msgctxt "field:sale.opportunity.create_campaign.start,relation:"
|
||||
msgid "Relation"
|
||||
msgstr "Relació"
|
||||
|
||||
<<<<<<<
|
||||
=======
|
||||
msgctxt "field:sale.opportunity.create_campaign.start,relation_visible:"
|
||||
msgid "Relation Visible"
|
||||
msgstr "Relació visible"
|
||||
|
||||
msgctxt "help:sale.opportunity.create_campaign.start,all_contacts:"
|
||||
msgid ""
|
||||
"If marked a lead will be created for each contact of the selected type. "
|
||||
>>>>>>>
|
||||
msgctxt "field:sale.opportunity.create_campaign.start,relation_visible:"
|
||||
msgid "Relation Visible"
|
||||
msgstr "Relació visible"
|
||||
|
||||
msgctxt "help:sale.opportunity.create_campaign.start,all_contacts:"
|
||||
msgid ""
|
||||
"If marked a lead will be created for each contact of the selected type. "
|
||||
|
@ -17,3 +111,25 @@ msgid ""
|
|||
msgstr ""
|
||||
"Si es marca es generarà una iniciativa per a cada un dels contactes del "
|
||||
"tipus seleccionat. Sinó només s'utilitzarà el primer."
|
||||
|
||||
msgctxt "help:sale.opportunity.create_campaign.start,create_leads:"
|
||||
msgid ""
|
||||
"If marked a lead will be created for each party and related to the party"
|
||||
msgstr ""
|
||||
"Si es marca es crearà una iniciativa per a cada tercer, i es relacionarà amb"
|
||||
" la campanya."
|
||||
|
||||
msgctxt "wizard_button:sale.opportunity.create_campaign,start,create_:"
|
||||
msgid "Create"
|
||||
msgstr "Crear"
|
||||
|
||||
msgctxt "help:sale.opportunity.create_campaign.start,create_leads:"
|
||||
msgid ""
|
||||
"If marked a lead will be created for each party and related to the party"
|
||||
msgstr ""
|
||||
"Si es marca es crearà una iniciativa per a cada tercer, i es relacionarà amb"
|
||||
" la campanya."
|
||||
|
||||
msgctxt "wizard_button:sale.opportunity.create_campaign,start,create_:"
|
||||
msgid "Create"
|
||||
msgstr "Crear"
|
||||
|
|
116
locale/es_ES.po
116
locale/es_ES.po
|
@ -2,14 +2,108 @@
|
|||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.relation.type,available_on_campaign:"
|
||||
msgid "Available on campaing"
|
||||
msgstr "Disponible en campañas"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,campaing:"
|
||||
msgid "Campaign"
|
||||
msgstr "Campaña"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,create_date:"
|
||||
msgid "Create Date"
|
||||
msgstr "Fecha de creación"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,create_uid:"
|
||||
msgid "Create User"
|
||||
msgstr "Usuario de creación"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,id:"
|
||||
msgid "ID"
|
||||
msgstr "Identificador"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,party:"
|
||||
msgid "Party"
|
||||
msgstr "Tercero"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,rec_name:"
|
||||
msgid "Name"
|
||||
msgstr "Nombre"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,write_date:"
|
||||
msgid "Write Date"
|
||||
msgstr "Fecha modificación"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,write_uid:"
|
||||
msgid "Write User"
|
||||
msgstr "Usuario modificación"
|
||||
|
||||
msgctxt "field:party.relation.type,available_on_campaign:"
|
||||
msgid "Available on campaing"
|
||||
msgstr "Disponible en campañas"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,campaing:"
|
||||
msgid "Campaign"
|
||||
msgstr "Campaña"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,create_date:"
|
||||
msgid "Create Date"
|
||||
msgstr "Fecha de creación"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,create_uid:"
|
||||
msgid "Create User"
|
||||
msgstr "Usuario de creación"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,id:"
|
||||
msgid "ID"
|
||||
msgstr "Identificador"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,party:"
|
||||
msgid "Party"
|
||||
msgstr "Tercero"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,rec_name:"
|
||||
msgid "Name"
|
||||
msgstr "Nombre"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,write_date:"
|
||||
msgid "Write Date"
|
||||
msgstr "Fecha modificación"
|
||||
|
||||
msgctxt "field:sale.opportunity.campaign-party.party,write_uid:"
|
||||
msgid "Write User"
|
||||
msgstr "Usuario modificación"
|
||||
|
||||
msgctxt "field:sale.opportunity.create_campaign.start,all_contacts:"
|
||||
msgid "All Contacts"
|
||||
msgstr "Todos los contactos"
|
||||
|
||||
msgctxt "field:sale.opportunity.create_campaign.start,create_leads:"
|
||||
msgid "Create Leads"
|
||||
msgstr "Crear iniciativas"
|
||||
|
||||
msgctxt "field:sale.opportunity.create_campaign.start,create_leads:"
|
||||
msgid "Create Leads"
|
||||
msgstr "Crear iniciativas"
|
||||
|
||||
msgctxt "field:sale.opportunity.create_campaign.start,relation:"
|
||||
msgid "Relation"
|
||||
msgstr "Relación"
|
||||
|
||||
<<<<<<<
|
||||
=======
|
||||
msgctxt "field:sale.opportunity.create_campaign.start,relation_visible:"
|
||||
msgid "Relation Visible"
|
||||
msgstr "Relación visible"
|
||||
|
||||
msgctxt "help:sale.opportunity.create_campaign.start,all_contacts:"
|
||||
msgid ""
|
||||
"If marked a lead will be created for each contact of the selected type. "
|
||||
>>>>>>>
|
||||
msgctxt "field:sale.opportunity.create_campaign.start,relation_visible:"
|
||||
msgid "Relation Visible"
|
||||
msgstr "Relación visible"
|
||||
|
||||
msgctxt "help:sale.opportunity.create_campaign.start,all_contacts:"
|
||||
msgid ""
|
||||
"If marked a lead will be created for each contact of the selected type. "
|
||||
|
@ -17,3 +111,25 @@ msgid ""
|
|||
msgstr ""
|
||||
"Si se merca se creará una iniciativa para cada uno de los contactos del tipo"
|
||||
" seleccionado. Sino, solo se utilizará el primero."
|
||||
|
||||
msgctxt "help:sale.opportunity.create_campaign.start,create_leads:"
|
||||
msgid ""
|
||||
"If marked a lead will be created for each party and related to the party"
|
||||
msgstr ""
|
||||
"Si se marca se creará una iniciativa para cada tercero relacionada con la "
|
||||
"campaña."
|
||||
|
||||
msgctxt "wizard_button:sale.opportunity.create_campaign,start,create_:"
|
||||
msgid "Create"
|
||||
msgstr "Crear"
|
||||
|
||||
msgctxt "help:sale.opportunity.create_campaign.start,create_leads:"
|
||||
msgid ""
|
||||
"If marked a lead will be created for each party and related to the party"
|
||||
msgstr ""
|
||||
"Si se marca se creará una iniciativa para cada tercero relacionada con la "
|
||||
"campaña."
|
||||
|
||||
msgctxt "wizard_button:sale.opportunity.create_campaign,start,create_:"
|
||||
msgid "Create"
|
||||
msgstr "Crear"
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
from trytond.model import fields
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Bool, Eval
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
__all__ = ['Relation', 'CreateCampaignStart', 'CreateCampaign']
|
||||
__all__ = ['Relation', 'PartyCampaign', 'CreateCampaignStart',
|
||||
'CreateCampaign']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
|
@ -51,6 +53,48 @@ class Relation:
|
|||
return [('id', reverse[operator], allowed)]
|
||||
|
||||
|
||||
class PartyCampaign:
|
||||
__name__ = 'sale.opportunity.campaign-party.party'
|
||||
|
||||
def _get_opportunities(self):
|
||||
opportunities = super(PartyCampaign, self)._get_opportunities()
|
||||
relation = Transaction().context.get('relation')
|
||||
if relation:
|
||||
new_opportunities = []
|
||||
for relation in self.party.relations:
|
||||
if relation.type.id == relation:
|
||||
for opportunity in opportunities:
|
||||
new_opportunity = opportunity.copy()
|
||||
new_opportunity['contact'] = relation.to.id
|
||||
new_opportunities.append(new_opportunity)
|
||||
if not self.start.all_contacts:
|
||||
break
|
||||
if new_opportunities:
|
||||
return new_opportunities
|
||||
return opportunities
|
||||
|
||||
|
||||
class PartyCampaign:
|
||||
__name__ = 'sale.opportunity.campaign-party.party'
|
||||
|
||||
def _get_opportunities(self):
|
||||
opportunities = super(PartyCampaign, self)._get_opportunities()
|
||||
relation = Transaction().context.get('relation')
|
||||
if relation:
|
||||
new_opportunities = []
|
||||
for relation in self.party.relations:
|
||||
if relation.type.id == relation:
|
||||
for opportunity in opportunities:
|
||||
new_opportunity = opportunity.copy()
|
||||
new_opportunity['contact'] = relation.to.id
|
||||
new_opportunities.append(new_opportunity)
|
||||
if not self.start.all_contacts:
|
||||
break
|
||||
if new_opportunities:
|
||||
return new_opportunities
|
||||
return opportunities
|
||||
|
||||
|
||||
class CreateCampaignStart:
|
||||
__name__ = 'sale.opportunity.create_campaign.start'
|
||||
relation_visible = fields.Boolean('Relation Visible')
|
||||
|
@ -80,19 +124,9 @@ class CreateCampaign:
|
|||
config = Config(1)
|
||||
return {'relation_visible': bool(config.relation_types)}
|
||||
|
||||
def _get_opportunities(self, campaign, party):
|
||||
opportunities = super(CreateCampaign, self)._get_opportunities(
|
||||
campaign, party)
|
||||
def do_leads(self, action):
|
||||
context = {}
|
||||
if self.start.relation:
|
||||
new_opportunities = []
|
||||
for relation in party.relations:
|
||||
if relation.type == self.start.relation:
|
||||
for opportunity in opportunities:
|
||||
new_opportunity = opportunity.copy()
|
||||
new_opportunity['contact'] = relation.to.id
|
||||
new_opportunities.append(new_opportunity)
|
||||
if not self.start.all_contacts:
|
||||
break
|
||||
if new_opportunities:
|
||||
return new_opportunities
|
||||
return opportunities
|
||||
context['relation'] = self.start.relation.id
|
||||
with Transaction().set_context(context):
|
||||
return super(CreateCampaign, self).do_leads(action)
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
<!--The COPYRIGHT file at the top level of this repository
|
||||
contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/field[@name='campaign']" position="after">
|
||||
<xpath expr="/form/field[@name='create_leads']" position="after">
|
||||
<newline/>
|
||||
<label name="relation"/>
|
||||
<field name="relation"/>
|
||||
<label name="all_contacts"/>
|
||||
|
|
Loading…
Reference in New Issue