Add parties related CSV Profile
This commit is contained in:
parent
19ede31c2a
commit
f6125143a1
|
@ -7,5 +7,7 @@ from .csv_profile import *
|
|||
|
||||
def register():
|
||||
Pool.register(
|
||||
CSVProfile,
|
||||
CSVProfileParty,
|
||||
CSVImport,
|
||||
module='csv_import_getmail', type_='model')
|
||||
|
|
|
@ -3,12 +3,29 @@
|
|||
# the full copyright notices and license terms.
|
||||
from datetime import datetime
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.model import ModelSQL, ModelView, fields
|
||||
import logging
|
||||
|
||||
__all__ = ['CSVImport']
|
||||
__all__ = ['CSVProfile', 'CSVProfileParty', 'CSVImport']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
class CSVProfile(ModelSQL, ModelView):
|
||||
__name__ = 'csv.profile'
|
||||
parties = fields.Many2Many('csv.profile-party.party',
|
||||
'profile', 'party', 'Parties')
|
||||
|
||||
|
||||
class CSVProfileParty(ModelSQL):
|
||||
'Profile - Party'
|
||||
__name__ = 'csv.profile-party.party'
|
||||
_table = 'csv_profile_party_rel'
|
||||
profile = fields.Many2One('csv.profile', 'CSV Profile', ondelete='CASCADE',
|
||||
required=True, select=True)
|
||||
party = fields.Many2One('party.party', 'Party',
|
||||
ondelete='CASCADE', required=True, select=True)
|
||||
|
||||
|
||||
class CSVImport:
|
||||
__name__ = 'csv.import'
|
||||
|
||||
|
@ -27,7 +44,7 @@ class CSVImport:
|
|||
party, _ = GetMail.get_party_from_email(sender)
|
||||
if not party:
|
||||
continue
|
||||
csv_profiles = CSVProfile.search([('party', '=', party)])
|
||||
csv_profiles = CSVProfile.search([('parties', 'in', [party])])
|
||||
if not csv_profiles:
|
||||
continue
|
||||
csv_profile = csv_profiles[0]
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="csv_profile_form_view">
|
||||
<field name="model">csv.profile</field>
|
||||
<field name="inherit" ref="csv_import.csv_profile_form_view"/>
|
||||
<field name="name">csv_profile_form</field>
|
||||
</record>
|
||||
|
||||
<!-- Access csv.archive -->
|
||||
<record model="ir.model.access" id="access_csv_archive_admin">
|
||||
<field name="model" search="[('model', '=', 'csv.archive')]"/>
|
||||
|
@ -19,6 +25,7 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
|||
<field name="perm_create" eval="False"/>
|
||||
<field name="perm_delete" eval="False"/>
|
||||
</record>
|
||||
|
||||
<!-- Access csv.import -->
|
||||
<record model="ir.model.access" id="access_csv_import_admin">
|
||||
<field name="model" search="[('model', '=', 'csv.import')]"/>
|
||||
|
@ -36,4 +43,4 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
|||
<field name="perm_delete" eval="False"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
</tryton>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of csv_import_getmail module for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath
|
||||
expr="/form/notebook/page[@id='configuration']"
|
||||
position="after">
|
||||
<page string="Parties" col="4" id="party">
|
||||
<separator string="Parties" id="parties" colspan="4"/>
|
||||
<field name="parties"/>
|
||||
</page>
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in New Issue