|
|
@ -28,14 +28,24 @@ class opendons_operation(models.Model): |
|
|
|
_name = 'opendons.operation' |
|
|
|
_description = 'opération marketing : mailing, emailing evenements' |
|
|
|
_inherit = ['mail.thread'] |
|
|
|
_check_company_auto = True |
|
|
|
#_order = "__last_update desc" |
|
|
|
#code=fields.Char(string='Code',required=True, translate=True,track_visibility='always') |
|
|
|
name=fields.Char(string='Name',required=True, translate=True,copy=False,default='operation',track_visibility='always') |
|
|
|
partner_count = fields.Integer(string="count",readonly=True) |
|
|
|
exported_date=fields.Date(string='Exported Date',track_visibility='always') |
|
|
|
exported_date=fields.Date(string='Exported Date',track_visibility='always', readonly=True) |
|
|
|
#end_date=fields.Date(string='Date end',required=True, translate=True,track_visibility='always') |
|
|
|
partner_ids = fields.Many2many('res.partner', 'partner_operation_rel', 'partner_id', 'operation_id', string='partners') |
|
|
|
#contacts exclus de l'opération |
|
|
|
company_id = fields.Many2one( |
|
|
|
"res.company", |
|
|
|
string="Company", |
|
|
|
required=True, |
|
|
|
states={"exported": [("readonly", True)]}, |
|
|
|
default=lambda self: self.env.company |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
partner_excl_ids=fields.Many2many('res.partner', 'partner_excl_operation_rel', 'partner_id', 'operation_id', string='excluded partners') |
|
|
|
chanel=fields.Selection([ |
|
|
|
('mail', 'Mailing'), |
|
|
@ -62,10 +72,10 @@ class opendons_operation(models.Model): |
|
|
|
ondelete='restrict', |
|
|
|
default=_default_currency |
|
|
|
) |
|
|
|
_sql_constraints = [ |
|
|
|
('name_uniq', 'unique (name)', "Name already exists !") |
|
|
|
# _sql_constraints = [ |
|
|
|
# ('name_uniq', 'unique (name)', "Name already exists !") |
|
|
|
|
|
|
|
] |
|
|
|
# ] |
|
|
|
|
|
|
|
number_of_sending = fields.Integer( |
|
|
|
compute='_compute_number_of_sending', |
|
|
@ -192,11 +202,7 @@ class opendons_operation(models.Model): |
|
|
|
segexcl=self.env['opendons.segment'].search(['&',('operation_id','=',self.id),('exclusion','=',True)]) |
|
|
|
segments=self.env['opendons.segment'].search(['&',('operation_id','=',self.id),('exclusion','=',False)],order='sequence asc') |
|
|
|
|
|
|
|
#[["id","not in",[1,3,7,8,10]]] |
|
|
|
#["&",["id","not in",[22]],["id","not in",[1,3,7,8,10]]] |
|
|
|
|
|
|
|
#List of Domain operators: ! (Not), | (Or), & (And) |
|
|
|
#List of Term operators: '=', '!=', '<=', '<', '>', '>=', '=?', '=like', '=ilike', 'like', 'not like', 'ilike', 'not ilike', 'in', 'not in', 'child_of' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
i=1 |
|
|
@ -246,7 +252,7 @@ class opendons_operation(models.Model): |
|
|
|
sg_1=sg |
|
|
|
|
|
|
|
i=i+1 |
|
|
|
self.exported_date=fields.Date.context_today(self) |
|
|
|
self.exported_date=fields.Date.context_today(self, readonly=True) |
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
@ -254,8 +260,15 @@ class opendons_operation(models.Model): |
|
|
|
|
|
|
|
@api.model |
|
|
|
def create(self,vals): |
|
|
|
|
|
|
|
|
|
|
|
op=self.env['opendons.operation'].search(['&',('name','=',vals['name']),('company_id','=',int(self.env.user.company_id))]) |
|
|
|
|
|
|
|
if "company_id" in vals: |
|
|
|
self = self.with_company(vals["company_id"]) |
|
|
|
|
|
|
|
if op : raise Warning('name already exist') |
|
|
|
res=super(opendons_operation, self).create(vals) |
|
|
|
raise Warning(res.company_id) |
|
|
|
#création du segment d'exclusion |
|
|
|
vals2={} |
|
|
|
vals2['operation_id']=res.id |
|
|
|