Browse Source

referentiel postal

master
root 3 years ago
parent
commit
3d4f1be723
8 changed files with 207 additions and 29 deletions
  1. +2
    -1
      __manifest__.py
  2. +46
    -4
      i18n/fr.po
  3. +1
    -0
      models/__init__.py
  4. +21
    -0
      models/laposte_ref.py
  5. +25
    -17
      models/partner.py
  6. +2
    -0
      security/ir.model.access.csv
  7. +50
    -0
      views/laposte_ref.xml
  8. +60
    -7
      views/partner.xml

+ 2
- 1
__manifest__.py View File

@ -45,7 +45,8 @@
'wizard/operation_duplicate_wizard.xml',
'report/report_donationtax.xml',
'report/report.xml',
'views/donation_tax_receipt.xml'
'views/donation_tax_receipt.xml',
'views/laposte_ref.xml'
#'views/website_donation.xml'


+ 46
- 4
i18n/fr.po View File

@ -15,6 +15,47 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: base
#: model_terms:ir.ui.view,arch_db:base.view_partner_form
msgid ""
"<span class=\"o_form_label o_td_label\" name=\"address_name\">\n"
" <b attrs=\"{'invisible': [('type', '!=', 'contact')]}\">Company Address</b>\n"
" <b attrs=\"{'invisible': [('type', '!=', 'invoice')]}\">Invoice Address</b>\n"
" <b attrs=\"{'invisible': [('type', '!=', 'delivery')]}\">Delivery Address</b>\n"
" <b attrs=\"{'invisible': [('type', '!=', 'other')]}\">Other Address</b>\n"
" <b attrs=\"{'invisible': [('type', '!=', 'private')]}\">Private Address</b>\n"
" <b attrs=\"{'invisible': [('type', '!=', False)]}\">Address</b>\n"
" </span>"
msgstr ""
"<span class=\"o_form_label o_td_label\" name=\"address_name\">\n"
" <b attrs=\"{'invisible': [('type', '!=', 'contact')]}\">Adresse de la société</b>\n"
" <b attrs=\"{'invisible': [('type', '!=', 'invoice')]}\">Adresse de facturation</b>\n"
" <b attrs=\"{'invisible': [('type', '!=', 'delivery')]}\">Adresse de livraison</b>\n"
" <b attrs=\"{'invisible': [('type', '!=', 'other')]}\">Autre Adresse</b>\n"
" <b attrs=\"{'invisible': [('type', '!=', 'private')]}\">Adresse</b>\n"
" <b attrs=\"{'invisible': [('type', '!=', False)]}\">Adresse</b>\n"
" </span>"
#. module: base
#: model:ir.model.fields,field_description:base.field_res_partner__title
#: model:ir.model.fields,field_description:base.field_res_partner_title__name
#: model:ir.model.fields,field_description:base.field_res_users__title
#: model_terms:ir.ui.view,arch_db:opendons.view_partner_tree
msgid "Title"
msgstr "Civilité"
#. module: account
#: model_terms:ir.ui.view,arch_db:account.view_partner_property_form
msgid "Invoicing"
msgstr "Infos bancaires"
#. module: opendons
#: model:ir.model.fields,field_description:opendons.field_res_partner__locality
#: model_terms:ir.ui.view,arch_db:opendons.view_partner_form
msgid "Locality"
msgstr "Lieu dit"
#. module: opendons
#: model:ir.model.fields,field_description:opendons.field_res_partner__address_count
#: model:ir.model.fields,field_description:opendons.field_res_users__address_count
@ -641,8 +682,9 @@ msgstr ""
#. module: opendons
#: model:ir.model.fields,field_description:opendons.field_res_partner__key
#: model:ir.model.fields,field_description:opendons.field_res_users__key
#: model_terms:ir.ui.view,arch_db:opendons.view_partner_tree
msgid "Key"
msgstr ""
msgstr "Clé"
#. module: opendons
#: model:ir.model.fields,field_description:opendons.field_donation_donation____last_update
@ -976,19 +1018,19 @@ msgstr "Trimestriel"
#: model:ir.actions.act_window,name:opendons.donation_recurring_action
#: model:ir.ui.menu,name:opendons.recurring_donation_menu
msgid "Recurring Donations"
msgstr "Dons récurrents"
msgstr "Prélèvements automatiques"
#. module: opendons
#: model:ir.ui.menu,name:opendons.recurring_donation_title_menu
#: model:ir.ui.menu,name:opendons.recurring_donation_top_menu
msgid "Recurring donations"
msgstr "Dons récurrents"
msgstr "Prélèvements automatiques"
#. module: opendons
#: model:ir.actions.act_window,name:opendons.act_partner_recurring_donation
#: model_terms:ir.ui.view,arch_db:opendons.view_partner_form
msgid "Recurring_donation"
msgstr ""
msgstr "Prélèvements automatiques"
#. module: opendons
#: model:ir.model.fields.selection,name:opendons.selection__opendons_returnmail__return_type__refusee


+ 1
- 0
models/__init__.py View File

@ -16,3 +16,4 @@ from . import aggregate
from . import duplicate
from . import template_rf
from . import donation_tax_receipt
from . import laposte_ref

+ 21
- 0
models/laposte_ref.py View File

@ -0,0 +1,21 @@
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_laposte_ref(models.Model):
_name = 'opendons.laposte_ref'
_description = 'La Poste referential'
#https://www.data.gouv.fr/fr/datasets/r/554590ab-ae62-40ac-8353-ee75162c05ee
code_commune_insee=fields.Char('Code_commune_insee')
nom_commune=fields.Char('Nom_commune')
code_postal=fields.Integer('Code postal')
ligne_5=fields.Char('Ligne 5')
libelle_acheminement=fields.Char('Libelle acheminement')
coordonnees_gps=fields.Char('coordonnees_gps')

+ 25
- 17
models/partner.py View File

@ -143,7 +143,16 @@ class partner(models.Model):
firstname=fields.Char(string="First name")
npai_count=fields.Integer(String="NPAI count", readonly=True)
source=fields.Char(String="source")
donor_id=fields.Char('Donor id',compute="_compute_donor_id")
def _compute_donor_id(self):
for rec in self:
rec.donor_id=str(rec.id)+rec.key
def _alpha(self,id):
alpha={}
alpha[0]='A'
@ -160,19 +169,18 @@ class partner(models.Model):
alpha[11]='L'
alpha[12]='M'
alpha[13]='N'
alpha[14]='O'
alpha[15]='P'
alpha[16]='Q'
alpha[17]='R'
alpha[18]='S'
alpha[19]='T'
alpha[20]='U'
alpha[21]='V'
alpha[22]='W'
alpha[23]='X'
alpha[24]='Y'
alpha[25]='Z'
return (alpha[id%26])
alpha[14]='P'
alpha[15]='Q'
alpha[16]='R'
alpha[17]='S'
alpha[18]='T'
alpha[19]='U'
alpha[20]='V'
alpha[21]='W'
alpha[22]='X'
alpha[23]='Y'
alpha[24]='Z'
return (alpha[id%25])
def _compute_key(self):
@ -282,9 +290,9 @@ class partner(models.Model):
regex = re.compile(r'(^(?:(?:IT|SM)\d{2}[A-Z]\d{22}|CY\d{2}[A-Z]\d{23}|NL\d{2}[A-Z]{4}\d{10}|LV\d{2}[A-Z]{4}\d{13}|(?:BG|BH|GB|IE)\d{2}[A-Z]{4}\d{14}|GI\d{2}[A-Z]{4}\d{15}|RO\d{2}[A-Z]{4}\d{16}|KW\d{2}[A-Z]{4}\d{22}|MT\d{2}[A-Z]{4}\d{23}|NO\d{13}|(?:DK|FI|GL|FO)\d{16}|MK\d{17}|(?:AT|EE|KZ|LU|XK)\d{18}|(?:BA|HR|LI|CH|CR)\d{19}|(?:GE|DE|LT|ME|RS)\d{20}|IL\d{21}|(?:AD|CZ|ES|MD|SA)\d{22}|PT\d{23}|(?:BE|IS)\d{24}|(?:FR|MR|MC)\d{25}|(?:AL|DO|LB|PL)\d{26}|(?:AZ|HU)\d{27}|(?:GR|MU)\d{28})$)+')
if not re.fullmatch(regex, self.acc_number):
#if not re.fullmatch(regex, self.acc_number):
raise Warning('Invalid IBAN')
# raise Warning('Invalid IBAN')
@api.constrains('acc_number')
def _onchange_acc_number(self):
@ -294,6 +302,6 @@ class partner(models.Model):
regex = re.compile(r'(/^(?:(?:IT|SM)\d{2}[A-Z]\d{22}|CY\d{2}[A-Z]\d{23}|NL\d{2}[A-Z]{4}\d{10}|LV\d{2}[A-Z]{4}\d{13}|(?:BG|BH|GB|IE)\d{2}[A-Z]{4}\d{14}|GI\d{2}[A-Z]{4}\d{15}|RO\d{2}[A-Z]{4}\d{16}|KW\d{2}[A-Z]{4}\d{22}|MT\d{2}[A-Z]{4}\d{23}|NO\d{13}|(?:DK|FI|GL|FO)\d{16}|MK\d{17}|(?:AT|EE|KZ|LU|XK)\d{18}|(?:BA|HR|LI|CH|CR)\d{19}|(?:GE|DE|LT|ME|RS)\d{20}|IL\d{21}|(?:AD|CZ|ES|MD|SA)\d{22}|PT\d{23}|(?:BE|IS)\d{24}|(?:FR|MR|MC)\d{25}|(?:AL|DO|LB|PL)\d{26}|(?:AZ|HU)\d{27}|(?:GR|MU)\d{28})$)+')
if not re.fullmatch(regex, self.acc_number):
#if not re.fullmatch(regex, self.acc_number):
raise Warning('Invalid IBAN')
# raise Warning('Invalid IBAN')

+ 2
- 0
security/ir.model.access.csv View File

@ -32,3 +32,5 @@ access_opendons_duplicate_partner,opendons_duplicate_partner,model_opendons_dupl
access_opendons_template_rf,opendons_template_rf,model_opendons_template_rf,donation.group_donation_manager,1,1,1,1
access_opendons_laposte_ref,opendons_laposte_ref,model_opendons_laposte_ref,donation.group_donation_manager,1,1,1,1

+ 50
- 0
views/laposte_ref.xml View File

@ -0,0 +1,50 @@
<odoo>
<data>
<!-- explicit list view definition -->
<record model="ir.ui.view" id="opendons.laposte_ref_list">
<field name="name">opendons_laposte_ref list</field>
<field name="model">opendons.laposte_ref</field>
<field name="arch" type="xml">
<tree>
<field name="code_commune_insee"/>
<field name="nom_commune"/>
<field name="code_postal"/>
<field name="ligne_5"/>
<field name="libelle_acheminement"/>
<field name="coordonnees_gps"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="opendons.laposte_ref_form" >
<field name="name">opendons_laposte_ref Form</field>
<field name="model">opendons.laposte_ref</field>
<field name="arch" type="xml">
<form string="laposte_ref_form">
<sheet>
<group name="main">
<field name="code_commune_insee"/>
<field name="nom_commune"/>
<field name="code_postal"/>
<field name="ligne_5"/>
<field name="libelle_acheminement"/>
<field name="coordonnees_gps"/>
</group>
</sheet>
</form>
</field>
</record>
</data>
</odoo>

+ 60
- 7
views/partner.xml View File

@ -80,7 +80,38 @@
</record>
<record id="contacts.action_contacts" model="ir.actions.act_window">
<field name="view_mode">tree,form,kanban</field>
</record>
<record id="contacts.action_contacts_view_kanban" model="ir.actions.act_window.view">
<field name="sequence" eval="4"/>
<field name="view_mode">kanban</field>
<field name="view_id" ref="base.res_partner_kanban_view"/>
<field name="act_window_id" ref="contacts.action_contacts"/>
</record>
<record id="view_partner_tree" model="ir.ui.view">
<field name="name">opendons.res.partner.tree</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_tree" />
<field name="arch" type="xml">
<xpath expr="/tree" position="replace">
<tree string="Contacts" sample="1" multi_edit="1">
<field name="donor_id" string="Donor Id"/>
<field name="title" string="Title"/>
<field name="display_name" string="Name"/>
<field name="firstname" string="Firstname"/>
<field name="phone" class="o_force_ltr" optional="show"/>
<field name="email" optional="show"/>
<field name="zip" optional="show"/>
<field name="city" optional="show"/>
</tree>
</xpath>
</field>
</record>
<record id="view_partner_form" model="ir.ui.view">
<field name="name">opendons.res.partner.form</field>
<field name="model">res.partner</field>
@ -88,7 +119,19 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='city']" position="before">
<xpath expr="//div[@class='o_address_format']" position="replace">
<field name="street" placeholder="Street..." class="o_address_street" attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
<field name="street2" placeholder="Street 2..." class="o_address_street" attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
<field name="zip" placeholder="ZIP" class="o_address_zip" attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
<field name="city" placeholder="City" class="o_address_city" attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
<field name="state_id" class="o_address_state" placeholder="State" options="{'no_open': True, 'no_quick_create': True}" attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}" context="{'country_id': country_id, 'default_country_id': country_id, 'zip': zip}"/>
<field name="country_id" placeholder="Country" class="o_address_country" options="{&quot;no_open&quot;: True, &quot;no_create&quot;: True}" attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
</xpath>
<xpath expr="//field[@name='zip']" position="before">
<field name="locality" string="Locality" placeholder="locality"/>
</xpath>
@ -113,13 +156,15 @@
<xpath expr="/form/sheet/div/h1" position="replace">
<group>
<group>
<field id="company" class="o_text_overflow" name="name" default_focus="1" placeholder="e.g. Lumber Inc" attrs="{'required' : [('type', '=', 'contact'),('is_company', '=', True)], 'invisible': [('is_company','=', False)]}"/>
<field name="donor_id"/>
<field name="title" options="{&quot;no_open&quot;: True}" placeholder="e.g. Mister" attrs="{'invisible': [('is_company', '=', True)]}"/>
<field id="individual" class="o_text_overflow" name="name" default_focus="1" placeholder="e.g. Brandom Freeman" attrs="{'required' : [('type', '=', 'contact'), ('is_company', '=', False)], 'invisible': [('is_company','=', True)]}"/>
<field name="firstname" attrs="{'invisible':[('is_company','=',True)]}"/>
<field name="title" options="{&quot;no_open&quot;: True}" placeholder="e.g. Mister" attrs="{'invisible': [('is_company', '=', True)]}"/>
<field name="id"/>
<field name="key"/>
<field name="source"/>
<field id="company" class="o_text_overflow" name="name" default_focus="1" placeholder="e.g. Lumber Inc" attrs="{'required' : [('type', '=', 'contact'),('is_company', '=', True)], 'invisible': [('is_company','=', False)]}"/>
<!-- <field name="source"/> -->
<!-- <field name="company_id"/> -->
@ -207,6 +252,12 @@
</field>
</record>
<record model="ir.actions.act_window" id="laposte_ref_action">
<field name="name">laposte_refs</field>
<field name="res_model">opendons.laposte_ref</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="opendons_qualifier_title_menu" name ="Qualifiers"
parent="contacts.menu_contacts" sequence="21"/>
@ -233,6 +284,8 @@
<menuitem id="opendons_duplicate_partner_menu" action="ir_action_find_duplicate_partner"
parent="opendons_duplicate_title_menu" sequence="2"/>
<menuitem id="opendons_laposte_ref_title_menu" name ="La Poste Referential" action="laposte_ref_action"
parent="contacts.menu_contacts" sequence="21"/>
</odoo>

Loading…
Cancel
Save