relation Many2Many equipment to subscription in model equipment
This commit is contained in:
parent
a140d69578
commit
a3046cf8f4
38
equipment.py
38
equipment.py
@ -1,5 +1,7 @@
|
|||||||
|
from collections import defaultdict
|
||||||
|
from trytond.pool import Pool
|
||||||
from trytond.model import ModelSQL, ModelView, fields
|
from trytond.model import ModelSQL, ModelView, fields
|
||||||
|
from trytond.exceptions import UserError
|
||||||
|
|
||||||
class OpticalEquipment(ModelSQL, ModelView):
|
class OpticalEquipment(ModelSQL, ModelView):
|
||||||
'Optical Equipment'
|
'Optical Equipment'
|
||||||
@ -8,7 +10,6 @@ class OpticalEquipment(ModelSQL, ModelView):
|
|||||||
company = fields.Many2One('company.company', "Company")
|
company = fields.Many2One('company.company', "Company")
|
||||||
location = fields.Many2One('stock.location', "Location")
|
location = fields.Many2One('stock.location', "Location")
|
||||||
party = fields.Many2One('party.party', "Party")
|
party = fields.Many2One('party.party', "Party")
|
||||||
#equipment_party = fields.Many2Many('optical.equipment-party.party', 'party', 'equipment', "Equipments")
|
|
||||||
party_address = fields.Many2One('party.address', "Party Address")
|
party_address = fields.Many2One('party.address', "Party Address")
|
||||||
#origin = fields.reference("Origin", selection='get_origin', select=True)
|
#origin = fields.reference("Origin", selection='get_origin', select=True)
|
||||||
product = fields.Many2One('product.product', "Product")
|
product = fields.Many2One('product.product', "Product")
|
||||||
@ -29,15 +30,30 @@ class OpticalEquipment(ModelSQL, ModelView):
|
|||||||
serial = fields.Char("Serial", size=None)
|
serial = fields.Char("Serial", size=None)
|
||||||
health_register = fields.Char("Health Register", size=None)
|
health_register = fields.Char("Health Register", size=None)
|
||||||
|
|
||||||
|
subscription_history = fields.Many2Many('sale.subscription-optical.equipment', 'equipment', 'subscription', "Subscriptions")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_origin():
|
def get_origin():
|
||||||
return None
|
return None
|
||||||
"""
|
|
||||||
class OpticalEquipmentParty(ModelSQL):
|
@classmethod
|
||||||
'Optical Equipment - Party'
|
def get_subscription_history(cls, records, names):
|
||||||
__name__ = 'optical.equipment-party.party'
|
pool = Pool()
|
||||||
_table = 'optical_equipment_party_party'
|
ids = []
|
||||||
|
for record in records:
|
||||||
party = fields.Many2One('party.party', 'Party', select=True)
|
ids.append(record.id)
|
||||||
equipment = fields.Many2One('optical.equipment', 'Equipment', select=True)
|
|
||||||
"""
|
Subscriptions = pool.get('sale.subscription-optical.equipment')
|
||||||
|
subscriptions = Subscriptions.search([("equipment", 'in', ids)])
|
||||||
|
#raise UserError(str(ids))
|
||||||
|
subscriptions_history_id = []
|
||||||
|
DICC = {}
|
||||||
|
|
||||||
|
for subscription in subscriptions:
|
||||||
|
DICC[subscription.equipment.id] = subscription.id
|
||||||
|
|
||||||
|
#raise UserError(str(type(subscriptions_history_id[0])))
|
||||||
|
#raise UserError(str(list(subscriptions_history_id[0])))
|
||||||
|
#raise UserError(str(type(subscriptions_history_id)))
|
||||||
|
|
||||||
|
return DICC
|
||||||
|
@ -10,5 +10,5 @@ class SubscriptionEquipment(ModelSQL):
|
|||||||
'Optical Equipment - Subscription'
|
'Optical Equipment - Subscription'
|
||||||
__name__ = 'sale.subscription-optical.equipment'
|
__name__ = 'sale.subscription-optical.equipment'
|
||||||
|
|
||||||
subscription = fields.Many2One('sale.subscription.line', 'Subscription Line', select=True)
|
subscription = fields.Many2One('sale.subscription', 'Subscription', select=True)
|
||||||
equipment = fields.Many2One('optical.equipment', 'Equipment', select=True)
|
equipment = fields.Many2One('optical.equipment', 'Equipment', select=True)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
this repository contains the full copyright notices and license terms. -->
|
this repository contains the full copyright notices and license terms. -->
|
||||||
<form>
|
<form>
|
||||||
|
<field name="subscription_history"/>
|
||||||
<label name="company"/>
|
<label name="company"/>
|
||||||
<field name="company"/>
|
<field name="company"/>
|
||||||
<label name="location"/>
|
<label name="location"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user