tab 'equipment invisible in line of purchase when product is 'equipment'
This commit is contained in:
parent
b23e83eb25
commit
98b33d8b8c
41
purchase.py
41
purchase.py
@ -62,7 +62,39 @@ class Line(metaclass=PoolMeta):
|
|||||||
address_equipment = fields.Many2One('party.address', "Direccion", required=True)
|
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")
|
||||||
|
product_equipment = fields.Boolean("Product Equipment")
|
||||||
|
|
||||||
|
def on_change_product(self):
|
||||||
|
if not self.product:
|
||||||
|
self.product_equipment = False
|
||||||
|
return
|
||||||
|
|
||||||
|
party = None
|
||||||
|
if self.purchase:
|
||||||
|
party = self.purchase.invoice_party or self.purchase.party
|
||||||
|
|
||||||
|
# Set taxes before unit_price to have taxes in context of purchase
|
||||||
|
# price
|
||||||
|
self.taxes = self.compute_taxes(party)
|
||||||
|
|
||||||
|
category = self.product.purchase_uom.category
|
||||||
|
if not self.unit or self.unit.category != category:
|
||||||
|
self.unit = self.product.purchase_uom
|
||||||
|
|
||||||
|
product_suppliers = list(self.product.product_suppliers_used(
|
||||||
|
**self._get_product_supplier_pattern()))
|
||||||
|
if len(product_suppliers) == 1:
|
||||||
|
self.product_supplier, = product_suppliers
|
||||||
|
elif (self.product_supplier
|
||||||
|
and self.product_supplier not in product_suppliers):
|
||||||
|
self.product_supplier = None
|
||||||
|
|
||||||
|
self.unit_price = self.compute_unit_price()
|
||||||
|
|
||||||
|
self.type = 'line'
|
||||||
|
self.amount = self.on_change_with_amount()
|
||||||
|
self.product_equipment = True
|
||||||
|
|
||||||
def default_address_equipment():
|
def default_address_equipment():
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Company = pool.get('company.company')
|
Company = pool.get('company.company')
|
||||||
@ -70,13 +102,10 @@ class Line(metaclass=PoolMeta):
|
|||||||
if company:
|
if company:
|
||||||
company = Company(company)
|
company = Company(company)
|
||||||
return company.party.addresses[0].id
|
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('product.equipment'),
|
'invisible': ~Eval('product_equipment', True),
|
||||||
})]
|
})]
|
||||||
"""
|
|
||||||
|
|
||||||
|
@ -14,4 +14,9 @@
|
|||||||
<field name="refurbish"/>
|
<field name="refurbish"/>
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<xpath
|
||||||
|
expr="/form/notebook/page[@id='general']/field[@name='product']" position="after">
|
||||||
|
<label name="product_equipment"/>
|
||||||
|
<field name="product_equipment"/>
|
||||||
|
</xpath>
|
||||||
</data>
|
</data>
|
||||||
|
Loading…
Reference in New Issue
Block a user