tab 'equipment invisible in line of purchase when product is 'equipment'

This commit is contained in:
sinergia 2022-06-30 09:32:01 -05:00
parent b23e83eb25
commit 98b33d8b8c
2 changed files with 40 additions and 6 deletions

View File

@ -62,6 +62,38 @@ 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()
@ -71,12 +103,9 @@ class Line(metaclass=PoolMeta):
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),
})] })]
"""

View File

@ -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>