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