add field address for default of the company to equipment in purchase
This commit is contained in:
parent
93f037923b
commit
b23e83eb25
@ -9,8 +9,8 @@ class OpticalEquipment(ModelSQL, ModelView):
|
||||
|
||||
company = fields.Many2One('company.company', "Company")
|
||||
location = fields.Many2One('stock.location', "Location")
|
||||
party = fields.Many2One('party.party', "Party")
|
||||
party_address = fields.Many2One('party.address', "Party Address")
|
||||
propietary = fields.Many2One('party.party', "Propietary")
|
||||
propietary_address = fields.Many2One('party.address', "Propietary Address", required=True)
|
||||
product = fields.Many2One('product.product', "Product")
|
||||
refurbish = fields.Boolean("Refurbish")
|
||||
equipment_type = fields.Char('type')
|
||||
|
20
purchase.py
20
purchase.py
@ -8,6 +8,8 @@ from trytond.i18n import gettext
|
||||
from .exceptions import (
|
||||
InvalidNumberPurchases)
|
||||
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
class Purchase(metaclass=PoolMeta):
|
||||
__name__ = 'purchase.purchase'
|
||||
|
||||
@ -27,8 +29,6 @@ class Purchase(metaclass=PoolMeta):
|
||||
if len(purchases) == 1:
|
||||
pool = Pool()
|
||||
Equipment = pool.get('optical_equipment.equipment')
|
||||
Line = pool.get('purchase.line')
|
||||
lines = []
|
||||
purchase = purchases[0]
|
||||
|
||||
for line in purchase.lines:
|
||||
@ -36,7 +36,7 @@ class Purchase(metaclass=PoolMeta):
|
||||
equipment = Equipment(
|
||||
company=line.company,
|
||||
equipment_type=line.product.equipment_type,
|
||||
party_address=line.address_equipment,
|
||||
propietary_address=line.address_equipment,
|
||||
product=line.product,
|
||||
risk=line.product.risk,
|
||||
use=line.product.use,
|
||||
@ -59,14 +59,24 @@ class Purchase(metaclass=PoolMeta):
|
||||
class Line(metaclass=PoolMeta):
|
||||
__name__ = 'purchase.line'
|
||||
|
||||
address_equipment = fields.Many2One('party.address', "Direccion")
|
||||
address_equipment = fields.Many2One('party.address', "Direccion", required=True)
|
||||
serial_equipment = fields.Char("Serial", size=None, required=True)
|
||||
refurbish = fields.Boolean("Refurbish")
|
||||
|
||||
def default_address_equipment():
|
||||
pool = Pool()
|
||||
Company = pool.get('company.company')
|
||||
company = Transaction().context.get('company')
|
||||
if company:
|
||||
company = Company(company)
|
||||
return company.party.addresses[0].id
|
||||
|
||||
"""
|
||||
@classmethod
|
||||
def view_attributes(cls):
|
||||
return super(Line, cls).view_attributes() + [
|
||||
('//page[@id="equipment"]', 'states', {
|
||||
'invisible': ~Eval('line.product.equipment'),
|
||||
'invisible': Eval('product.equipment'),
|
||||
})]
|
||||
"""
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
<field name="company"/>
|
||||
<label name="location"/>
|
||||
<field name="location"/>
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<label name="party_address"/>
|
||||
<field name="party_address"/>
|
||||
<label name="propietary"/>
|
||||
<field name="propietary"/>
|
||||
<label name="propietary_address"/>
|
||||
<field name="propietary_address"/>
|
||||
<label name="product"/>
|
||||
<field name="product"/>
|
||||
<label name="equipment_type"/>
|
||||
|
@ -4,8 +4,8 @@
|
||||
<tree>
|
||||
<field name="company"/>
|
||||
<field name="location"/>
|
||||
<field name="party"/>
|
||||
<field name="party_address"/>
|
||||
<field name="propietary"/>
|
||||
<field name="propietary_address"/>
|
||||
<field name="product"/>
|
||||
<field name="equipment_type"/>
|
||||
<field name="use"/>
|
||||
|
@ -4,8 +4,12 @@
|
||||
<xpath
|
||||
expr="/form/notebook/page[@id='notes']" position="before">
|
||||
<page string="Equipment" id="equipment">
|
||||
<label name="address_equipment"/>
|
||||
<field name="address_equipment"/>
|
||||
<newline/>
|
||||
<label name="serial_equipment"/>
|
||||
<field name="serial_equipment"/>
|
||||
<newline/>
|
||||
<label name="refurbish"/>
|
||||
<field name="refurbish"/>
|
||||
</page>
|
||||
|
Loading…
Reference in New Issue
Block a user