Minor fix
This commit is contained in:
parent
914d6ca126
commit
b1e41c66ae
|
@ -7,7 +7,6 @@ from . import sale
|
|||
from . import production
|
||||
from . import product
|
||||
from . import invoice
|
||||
from . import party
|
||||
from . import agent
|
||||
|
||||
|
||||
|
@ -25,7 +24,6 @@ def register():
|
|||
product.ProductMixOption,
|
||||
product.Product,
|
||||
invoice.InvoiceLine,
|
||||
party.Party,
|
||||
agent.Agent,
|
||||
module='sale_pos_frontend_rest', type_='model')
|
||||
Pool.register(
|
||||
|
|
9
party.py
9
party.py
|
@ -1,9 +0,0 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
|
||||
class Party(metaclass=PoolMeta):
|
||||
__name__ = 'party.party'
|
||||
agent = fields.Many2One('commission.agent', 'Agent')
|
|
@ -5,11 +5,11 @@ from trytond.model import ModelView, ModelSQL, fields
|
|||
from trytond.pool import Pool
|
||||
|
||||
TYPE_VEHICLE = [
|
||||
('', ''),
|
||||
('motorcycle', 'Motorcycle'),
|
||||
('bicycle', 'Bicycle'),
|
||||
('Car', 'Car'),
|
||||
]
|
||||
('', ''),
|
||||
('motorcycle', 'Motorcycle'),
|
||||
('bicycle', 'Bicycle'),
|
||||
('Car', 'Car'),
|
||||
]
|
||||
|
||||
|
||||
class SaleShopTable(ModelSQL, ModelView):
|
||||
|
@ -50,59 +50,7 @@ class PartyConsumer(ModelSQL, ModelView):
|
|||
address = fields.Char('Address', required=True)
|
||||
id_number = fields.Char('Id Number')
|
||||
birthday = fields.Date('Birthday')
|
||||
party = fields.Function(fields.Many2One('party.party', 'Party'), 'get_party')
|
||||
notes = fields.Text('Notes')
|
||||
|
||||
def get_rec_name(self, name=None):
|
||||
return self.name + ' | ' + self.phone + ' | ' + self.address
|
||||
|
||||
def get_party(self, name):
|
||||
Party = Pool().get('party.party')
|
||||
parties = Party.search([('id_number', '=', self.id_number)])
|
||||
if not parties:
|
||||
return
|
||||
return parties[0].id
|
||||
|
||||
@classmethod
|
||||
def write(cls, records, values):
|
||||
for rec in records:
|
||||
if rec.id_number and not rec.party:
|
||||
Party = Pool().get('party.party')
|
||||
Party.create([{
|
||||
'name': rec.name,
|
||||
'type_document': '13',
|
||||
'id_number': rec.id_number,
|
||||
'addresses': [('create', [{
|
||||
'street': rec.address,
|
||||
}])],
|
||||
'contact_mechanisms': [
|
||||
('create', [
|
||||
{'type': 'phone', 'value': rec.phone},
|
||||
# {'type': 'email', 'value': email},
|
||||
])
|
||||
]
|
||||
}])
|
||||
super(PartyConsumer, cls).write(records, values)
|
||||
|
||||
@classmethod
|
||||
def create(cls, vals):
|
||||
records = super(PartyConsumer, cls).create(vals)
|
||||
print(records)
|
||||
for rec in records:
|
||||
if rec.id_number and not rec.party:
|
||||
Party = Pool().get('party.party')
|
||||
Party.create([{
|
||||
'name': rec.name,
|
||||
'type_document': '13',
|
||||
'id_number': rec.id_number,
|
||||
'addresses': [('create', [{
|
||||
'street': rec.address,
|
||||
}])],
|
||||
'contact_mechanisms': [
|
||||
('create', [
|
||||
{'type': 'phone', 'value': rec.phone},
|
||||
# {'type': 'email', 'value': email},
|
||||
])
|
||||
]
|
||||
}])
|
||||
return records
|
||||
|
|
|
@ -12,8 +12,6 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
|||
<field name="id_number"/>
|
||||
<label name="birthday"/>
|
||||
<field name="birthday"/>
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<separator name="notes" colspan="4"/>
|
||||
<field name="notes" colspan="4"/>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue