| @ -1,3 +1,6 @@ | |||||
| # -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||||
| from . import models | |||||
| from . import qualifier | |||||
| from . import partner | |||||
| from . import address | |||||
| from . import operation | |||||
| @ -0,0 +1,68 @@ | |||||
| # -*- coding: utf-8 -*- | |||||
| from odoo import models, fields, api | |||||
| from odoo.exceptions import UserError, ValidationError | |||||
| from psycopg2 import sql, DatabaseError | |||||
| from odoo.tools.safe_eval import safe_eval, datetime | |||||
| from werkzeug import utils | |||||
| class opendons_partneraddress(models.Model): | |||||
| _name = 'opendons.partneraddress' | |||||
| _description = 'adresses du contact' | |||||
| _inherit = ['mail.thread'] | |||||
| #Complément d’identification du destinataire ou point de remise à l’intérieur du bâtiment : N° appartement, boite aux lettres, étage, couloir | |||||
| complement_ident = fields.Char(string='N° appartment,floor',track_visibility='always') | |||||
| #Complément d’identification du point géographique – extérieur du bâtiment : entrée, tour, bâtiment, immeuble, résidence | |||||
| complement_geo = fields.Char(string='entry,tower,bat',track_visibility='always') | |||||
| #Numéro et libellé de la voie | |||||
| street1 = fields.Char(string='street1', track_visibility='always') | |||||
| #Lieu dit ou service particulier de distribution – Poste restante, boite postale, etc. | |||||
| street2 = fields.Char(string='street2',track_visibility='always') | |||||
| #Code postal | |||||
| postalcode = fields.Char(string='Postal code',track_visibility='always') | |||||
| #Ville | |||||
| city = fields.Char(string='City', track_visibility='always') | |||||
| #Pays | |||||
| country = fields.Char(string='Country', track_visibility='always') | |||||
| #Compteur NPAI | |||||
| npai=fields.Integer(readonly=True,string='NPAI counter',default=0,track_visibility='always') | |||||
| #active | |||||
| active=fields.Boolean(string='active',default=False,track_visibility='always') | |||||
| date_inactive=fields.Date(readonly=True,string='Date inactive',track_visibility='always') | |||||
| partner_id = fields.Many2one( | |||||
| 'res.partner', | |||||
| string='partner', | |||||
| required=True, | |||||
| index=True, | |||||
| readonly=True, | |||||
| track_visibility='onchange', | |||||
| ondelete='restrict' | |||||
| ) | |||||
| def write(self,vals): | |||||
| for val in vals: | |||||
| if val=='active' and not vals['active']: | |||||
| date_inactive=fields.Date.context_today(self) | |||||
| if val=='active' and vals['active']: | |||||
| date_inactive=False | |||||
| vals['npai']=0 | |||||
| vals['date_inactive']=date_inactive | |||||
| #self.message_post(body=_('remise à zero du compteur NPAI')) | |||||
| res = super(opendons_partneraddress, self).write(vals) | |||||
| #Your code goes here | |||||
| return res | |||||
| @ -0,0 +1,89 @@ | |||||
| from odoo import models, fields, api | |||||
| from odoo.exceptions import UserError, ValidationError | |||||
| from psycopg2 import sql, DatabaseError | |||||
| from werkzeug import utils | |||||
| class opendons_operation(models.Model): | |||||
| _name = 'opendons.operation' | |||||
| _description = 'opération marketing : mailing, emailing evenements' | |||||
| _inherit = ['mail.thread'] | |||||
| code=fields.Char(string='Code',required=True, translate=True,track_visibility='always') | |||||
| name=fields.Char(string='Name',required=True, translate=True,track_visibility='always') | |||||
| begin_date=fields.Date(string='Date begin',required=True, translate=True,track_visibility='always') | |||||
| end_date=fields.Date(string='Date end',required=True, translate=True,track_visibility='always') | |||||
| chanel=fields.Selection([ | |||||
| ('mail', 'Mailing'), | |||||
| ('email', 'E-mailing'), | |||||
| ('event', 'Event')], | |||||
| string='Chanel',required=True, translate=True,track_visibility='always') | |||||
| user_id = fields.Many2one('res.users', string='Author', default=lambda self: self.env.uid) | |||||
| cost = fields.Monetary( | |||||
| string='Cost', | |||||
| currency_field='currency_id') | |||||
| @api.model | |||||
| def _default_currency(self): | |||||
| company = self.env['res.company']._company_default_get( | |||||
| 'opendons.operation') | |||||
| return company.currency_id | |||||
| currency_id = fields.Many2one( | |||||
| 'res.currency', | |||||
| string='Currency', | |||||
| required=True, | |||||
| track_visibility='onchange', | |||||
| ondelete='restrict', | |||||
| default=_default_currency | |||||
| ) | |||||
| _sql_constraints = [ | |||||
| ('name_uniq', 'unique (name)', "Name already exists !"), | |||||
| ('code_uniq', 'unique (code)', "Code already exists !"), | |||||
| ] | |||||
| number_of_sending = fields.Integer( | |||||
| compute='_compute_number_of_sending', | |||||
| string="# of sending", | |||||
| readonly=True | |||||
| ) | |||||
| segment_ids = fields.One2many( | |||||
| 'opendons.segment', | |||||
| 'operation_id', | |||||
| string='Segments', | |||||
| required=True, | |||||
| track_visibility='onchange') | |||||
| class opendons_segment(models.Model): | |||||
| _name = 'opendons.segment' | |||||
| _description = 'operation marketing segment : a segment is a part of contacts selected for an operation ' | |||||
| _inherit = ['mail.thread'] | |||||
| code=fields.Char(string='Code',required=True, translate=True,track_visibility='always') | |||||
| name=fields.Char(string='Name',required=True, translate=True,track_visibility='always') | |||||
| cost = fields.Monetary( | |||||
| string='Cost', | |||||
| currency_field='currency_id') | |||||
| @api.model | |||||
| def _default_currency(self): | |||||
| company = self.env['res.company']._company_default_get( | |||||
| 'opendons.segment') | |||||
| return company.currency_id | |||||
| currency_id = fields.Many2one( | |||||
| 'res.currency', | |||||
| string='Currency', | |||||
| required=True, | |||||
| track_visibility='onchange', | |||||
| ondelete='restrict', | |||||
| default=_default_currency | |||||
| ) | |||||
| operation_id = fields.Many2one( | |||||
| 'opendons.operation','Operation', | |||||
| ondelete='cascade', | |||||
| track_visibility='always') | |||||
| @ -0,0 +1,56 @@ | |||||
| from odoo import models, fields, api | |||||
| from odoo.exceptions import UserError, ValidationError | |||||
| from psycopg2 import sql, DatabaseError | |||||
| from werkzeug import utils | |||||
| class partner(models.Model): | |||||
| _inherit = 'res.partner' | |||||
| @api.depends('qualifier_ids.partner_id') | |||||
| def _compute_qualifier_count(self): | |||||
| # The current user may not have access rights for donations | |||||
| for partner in self: | |||||
| try: | |||||
| partner.qualifier_count = len(partner.qualifier_ids) | |||||
| except Exception: | |||||
| partner.qualifier_count = 0 | |||||
| def _compute_address_count(self): | |||||
| # The current user may not have access rights for donations | |||||
| for partner in self: | |||||
| try: | |||||
| partner.address_count = len(partner.address_ids) | |||||
| except Exception: | |||||
| partner.address_count = 0 | |||||
| qualifier_ids = fields.One2many( | |||||
| 'opendons_qualifier.partnerqualifier', | |||||
| 'partner_id', | |||||
| string='Qualifier', | |||||
| readonly=True | |||||
| ) | |||||
| qualifier_count = fields.Integer( | |||||
| compute='_compute_qualifier_count', | |||||
| string="# of Qualifiers", | |||||
| readonly=True | |||||
| ) | |||||
| address_ids = fields.One2many( | |||||
| 'opendons.partneraddress', | |||||
| 'partner_id', | |||||
| string='Address', | |||||
| readonly=True | |||||
| ) | |||||
| address_count = fields.Integer( | |||||
| compute='_compute_address_count', | |||||
| string="# of Addresses", | |||||
| readonly=True | |||||
| ) | |||||
| @ -0,0 +1,73 @@ | |||||
| # -*- coding: utf-8 -*- | |||||
| from odoo import models, fields, api | |||||
| from odoo.exceptions import UserError, ValidationError | |||||
| from psycopg2 import sql, DatabaseError | |||||
| from werkzeug import utils | |||||
| class opendons_qualifierCategory(models.Model): | |||||
| _name = 'opendons_qualifier.category' | |||||
| _description = 'categories pour les qualificatifs' | |||||
| sql_constraints = [ | |||||
| ('category_uniq', 'UNIQUE((name))', 'This name already exists.') | |||||
| ] | |||||
| name = fields.Char('Name', required=True) | |||||
| order= fields.Integer() | |||||
| description = fields.Text() | |||||
| @api.constrains('name') | |||||
| def _check_name(self): | |||||
| count=self.search_count([('name','=',self.name),('id', '!=', self.id)]) | |||||
| if count>0: | |||||
| raise UserError('This name already exist') | |||||
| class opendons_qualifier(models.Model): | |||||
| _name = 'opendons_qualifier.qualifier' | |||||
| _description = 'qualificatifs de contacts' | |||||
| name = fields.Char() | |||||
| type=fields.Selection([('checkbox','checkbox'),('text','text'),('numerical','numerical')], default='checkbox') | |||||
| default_value = fields.Char() | |||||
| description = fields.Text() | |||||
| category_id = fields.Many2one( | |||||
| 'opendons_qualifier.category', string='Category', tracking=True, | |||||
| required=True) | |||||
| class opendons_partnerqualifier(models.Model): | |||||
| _name = 'opendons_qualifier.partnerqualifier' | |||||
| _description = 'qualificatifs pour stocker les valeurs au niveau du contact' | |||||
| value=fields.Char() | |||||
| qualifier_id=fields.Many2one('opendons_qualifier.qualifier',string='qualifier') | |||||
| category = fields.Char(related='qualifier_id.category_id.name') | |||||
| partner_id = fields.Many2one( | |||||
| 'res.partner', | |||||
| string='partner', | |||||
| required=True, | |||||
| index=True, | |||||
| readonly=True, | |||||
| track_visibility='onchange', | |||||
| ondelete='restrict' | |||||
| ) | |||||
| sql_constraints = [ | |||||
| ('qualifier_uniq', 'unique (qualifier_id,partner_id)', 'A qualifier could be defined only one time on same partner.') | |||||
| ] | |||||
| @api.constrains('qualifier_id') | |||||
| def _check_qualifier_id(self): | |||||
| for q in self: | |||||
| result=self.search_count([('qualifier_id','=',int(self.qualifier_id)),('id', '!=', self.id),('partner_id','=',int(self.partner_id))]) | |||||
| if result>0: | |||||
| raise UserError('A qualifier could be defined only one time on same partner.') | |||||
| @ -0,0 +1,88 @@ | |||||
| <odoo> | |||||
| <data> | |||||
| <!-- explicit list view definition --> | |||||
| <record model="ir.ui.view" id="opendons_module1.partneraddress_list"> | |||||
| <field name="name">opendons_partneraddress list</field> | |||||
| <field name="model">opendons.partneraddress</field> | |||||
| <field name="arch" type="xml"> | |||||
| <tree> | |||||
| <field name="active"/> | |||||
| <field name="partner_id"/> | |||||
| <field name="complement_ident"/> | |||||
| <field name="complement_geo"/> | |||||
| <field name="street1"/> | |||||
| <field name="street2"/> | |||||
| <field name="postalcode"/> | |||||
| <field name="city"/> | |||||
| <field name="country"/> | |||||
| </tree> | |||||
| </field> | |||||
| </record> | |||||
| <record id="opendons_module1.partneraddress_search" model="ir.ui.view"> | |||||
| <field name="name">opendons_partneraddress.search</field> | |||||
| <field name="model">opendons.partneraddress</field> | |||||
| <field name="arch" type="xml"> | |||||
| <search string="Search Adresses"> | |||||
| <field name="partner_id"/> | |||||
| </search> | |||||
| </field> | |||||
| </record> | |||||
| <record model="ir.ui.view" id="opendons_module1.partneraddress_form" > | |||||
| <field name="name">opendons_partneraddress Form</field> | |||||
| <field name="model">opendons.partneraddress</field> | |||||
| <field name="arch" type="xml"> | |||||
| <form string="partneraddress_form"> | |||||
| <sheet> | |||||
| <group name="main"> | |||||
| <field name="partner_id"/> | |||||
| <field name="complement_ident"/> | |||||
| <field name="complement_geo"/> | |||||
| <field name="street1"/> | |||||
| <field name="street2"/> | |||||
| <field name="postalcode"/> | |||||
| <field name="city"/> | |||||
| <field name="country"/> | |||||
| </group> | |||||
| <group name="dataquality"> | |||||
| <field name="active"/> | |||||
| <field name="date_inactive"/> | |||||
| <field name="npai"/> | |||||
| </group> | |||||
| </sheet> | |||||
| <div class="oe_chatter"> | |||||
| <field name="message_follower_ids" widget="mail_followers"/> | |||||
| <field name="message_ids" widget="mail_thread"/> | |||||
| </div> | |||||
| </form> | |||||
| </field> | |||||
| </record> | |||||
| <!-- actions opening views on models --> | |||||
| <record model="ir.actions.act_window" id="partneraddress_action"> | |||||
| <field name="name">partneraddresses</field> | |||||
| <field name="res_model">opendons.partneraddress</field> | |||||
| <field name="view_mode">tree,form</field> | |||||
| </record> | |||||
| </data> | |||||
| </odoo> | |||||
| @ -0,0 +1,10 @@ | |||||
| <odoo> | |||||
| <data> | |||||
| <menuitem id="operation_top_menu" sequence="15" | |||||
| name="operations"/> | |||||
| </data> | |||||
| </odoo> | |||||
| @ -0,0 +1,138 @@ | |||||
| <odoo> | |||||
| <data> | |||||
| <!-- explicit list view definition --> | |||||
| <record model="ir.ui.view" id="opendons_module1.category_list"> | |||||
| <field name="name">opendons_qualifier_category list</field> | |||||
| <field name="model">opendons_qualifier.category</field> | |||||
| <field name="arch" type="xml"> | |||||
| <tree> | |||||
| <field name="name"/> | |||||
| <field name="description"/> | |||||
| <field name="order"/> | |||||
| </tree> | |||||
| </field> | |||||
| </record> | |||||
| <record model="ir.ui.view" id="opendons_module1.qualifier_list"> | |||||
| <field name="name">opendons_qualifier list</field> | |||||
| <field name="model">opendons_qualifier.qualifier</field> | |||||
| <field name="arch" type="xml"> | |||||
| <tree> | |||||
| <field name="name"/> | |||||
| <field name="category_id"/> | |||||
| <field name="type"/> | |||||
| <field name="default_value"/> | |||||
| <field name="description"/> | |||||
| </tree> | |||||
| </field> | |||||
| </record> | |||||
| <record model="ir.ui.view" id="opendons_module1.partnerqualifier_list"> | |||||
| <field name="name">opendons_partnerqualifier list</field> | |||||
| <field name="model">opendons_qualifier.partnerqualifier</field> | |||||
| <field name="arch" type="xml"> | |||||
| <tree> | |||||
| <field name="category" string="category"/> | |||||
| <field name="qualifier_id"/> | |||||
| <field name="value"/> | |||||
| </tree> | |||||
| </field> | |||||
| </record> | |||||
| <record id="opendons_module1.partnerqualifier_search" model="ir.ui.view"> | |||||
| <field name="name">opendons_partnerqualifier.search</field> | |||||
| <field name="model">opendons_qualifier.partnerqualifier</field> | |||||
| <field name="arch" type="xml"> | |||||
| <search string="Search Qualifiers"> | |||||
| <field name="partner_id"/> | |||||
| </search> | |||||
| </field> | |||||
| </record> | |||||
| <record model="ir.ui.view" id="opendons_module1.partnerqualifier_form" > | |||||
| <field name="name">opendons_partnerqualifier Form</field> | |||||
| <field name="model">opendons_qualifier.partnerqualifier</field> | |||||
| <field name="arch" type="xml"> | |||||
| <form string="partnerqualifier_form"> | |||||
| <sheet> | |||||
| <label for="partner_id" string="Partner"/> | |||||
| <field name="partner_id"/> | |||||
| <br/> | |||||
| <label for="qualifier_id" string="Qualifier"/> | |||||
| <field name="qualifier_id"/> | |||||
| <br/> | |||||
| <label for="value" string="value"/> | |||||
| <field name="value"/> | |||||
| </sheet> | |||||
| </form> | |||||
| </field> | |||||
| </record> | |||||
| <!-- actions opening views on models --> | |||||
| <record model="ir.actions.act_window" id="category_action"> | |||||
| <field name="name">categories</field> | |||||
| <field name="res_model">opendons_qualifier.category</field> | |||||
| <field name="view_mode">tree,form</field> | |||||
| </record> | |||||
| <record model="ir.actions.act_window" id="qualifier_action"> | |||||
| <field name="name">qualifiers</field> | |||||
| <field name="res_model">opendons_qualifier.qualifier</field> | |||||
| <field name="view_mode">tree,form</field> | |||||
| </record> | |||||
| <record model="ir.actions.act_window" id="partnerqualifier_action"> | |||||
| <field name="name">partnerqualifiers</field> | |||||
| <field name="res_model">opendons_qualifier.partnerqualifier</field> | |||||
| <field name="view_mode">tree,form</field> | |||||
| </record> | |||||
| <!-- server action to the one above --> | |||||
| <!-- | |||||
| <record model="ir.actions.server" id="opendons_qualifier.action_server"> | |||||
| <field name="name">opendons_qualifier server</field> | |||||
| <field name="model_id" ref="model_opendons_qualifier_opendons_qualifier"/> | |||||
| <field name="state">code</field> | |||||
| <field name="code"> | |||||
| action = { | |||||
| "type": "ir.actions.act_window", | |||||
| "view_mode": "tree,form", | |||||
| "res_model": model._name, | |||||
| } | |||||
| </field> | |||||
| </record> | |||||
| --> | |||||
| <!-- Top menu item --> | |||||
| <!-- <menuitem name="opendons_qualifier" id="opendons_qualifier.menu_root" parent="contacts.menu_contacts"/> --> | |||||
| <!-- entries menu --> | |||||
| <!-- <menuitem name="categories" id="opendons_qualifier.category" parent="opendons_qualifier_menu" action="opendons_qualifier.category_action_window"/> | |||||
| <menuitem name="qualifiers" id="opendons_qualifier.qualifier" parent="opendons_qualifier_menu" action="opendons_qualifier.qualifier_action_window"/> --> | |||||
| <!-- actions --> | |||||
| <!-- <menuitem name="List" id="opendons_qualifier.menu_1_list" parent="opendons_qualifier.menu_1" | |||||
| action="opendons_qualifier.action_window"/> --> | |||||
| <!-- <menuitem name="Server to list" id="opendons_qualifier" parent="opendons_qualifier.menu_2" | |||||
| action="opendons_qualifier.action_server"/> --> | |||||
| </data> | |||||
| </odoo> | |||||