value for default 0 in fields of equipment
This commit is contained in:
parent
b7976c2b04
commit
054b78fd01
@ -13,7 +13,7 @@ def register():
|
|||||||
purchase.Line,
|
purchase.Line,
|
||||||
sale.Sale,
|
sale.Sale,
|
||||||
sale.SaleLine,
|
sale.SaleLine,
|
||||||
sale.CreateSubscriptionStart,
|
sale.CreateSubscriptionStart,
|
||||||
equipment.OpticalEquipment,
|
equipment.OpticalEquipment,
|
||||||
equipment.EquipmentMaintenance,
|
equipment.EquipmentMaintenance,
|
||||||
configuration_equipment.Configuration,
|
configuration_equipment.Configuration,
|
||||||
@ -22,7 +22,9 @@ def register():
|
|||||||
maintenance.MaintenanceLine,
|
maintenance.MaintenanceLine,
|
||||||
subscription.Subscription,
|
subscription.Subscription,
|
||||||
subscription.SubscriptionEquipment,
|
subscription.SubscriptionEquipment,
|
||||||
|
subscription.CreateContractInvoiceStart,
|
||||||
module='optical_equipment', type_='model')
|
module='optical_equipment', type_='model')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
sale.CreateSubscription,
|
sale.CreateSubscription,
|
||||||
|
subscription.CreateContractInvoice,
|
||||||
module='optical_equipment', type_='wizard')
|
module='optical_equipment', type_='wizard')
|
||||||
|
21
equipment.py
21
equipment.py
@ -97,10 +97,29 @@ class OpticalEquipment(DeactivableMixin, Workflow, ModelSQL, ModelView):
|
|||||||
maintenance_frequency = fields.Selection(_MAINTENANCE_FREQUENCY, "Maintenance Frequency",
|
maintenance_frequency = fields.Selection(_MAINTENANCE_FREQUENCY, "Maintenance Frequency",
|
||||||
depends=['propietary'])
|
depends=['propietary'])
|
||||||
|
|
||||||
|
purchase_origin = fields.Reference("Purchase Origin", selection='get_origin', select=True)
|
||||||
|
|
||||||
del _states_serial
|
del _states_serial
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_origin(cls):
|
||||||
|
'Return list of Model names for origin Reference'
|
||||||
|
pool = Pool()
|
||||||
|
Purchase = pool.get('purchase.purchase')
|
||||||
|
|
||||||
|
return [Purchase.__name__]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_origin(cls):
|
||||||
|
Model = Pool().get('ir.model')
|
||||||
|
get_name = Model.get_name
|
||||||
|
models = cls._get_origin()
|
||||||
|
|
||||||
|
return [(None, '')] + [(m, get_name(m)) for m in models]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
super(OpticalEquipment, cls).__setup__()
|
super(OpticalEquipment, cls).__setup__()
|
||||||
|
@ -138,7 +138,9 @@ msgctxt "field:product.template,analog_resolution:"
|
|||||||
msgid "Analog resolution"
|
msgid "Analog resolution"
|
||||||
msgstr "Resolución Analoga"
|
msgstr "Resolución Analoga"
|
||||||
|
|
||||||
|
msgctxt "field:product.template,a_factor_resolution:"
|
||||||
|
msgid "(a) Resolution"
|
||||||
|
msgstr "Factor a"
|
||||||
|
|
||||||
msgctxt "field:sale.configuration,subscription_sequence:"
|
msgctxt "field:sale.configuration,subscription_sequence:"
|
||||||
msgid "Subscription Sequence"
|
msgid "Subscription Sequence"
|
||||||
|
57
product.py
57
product.py
@ -127,21 +127,24 @@ class Template(metaclass=PoolMeta):
|
|||||||
states={'invisible': ~Bool(Eval('electrical_equipment'))})
|
states={'invisible': ~Bool(Eval('electrical_equipment'))})
|
||||||
frequency_uom = fields.Many2One('product.uom', "Frequency UOM",
|
frequency_uom = fields.Many2One('product.uom', "Frequency UOM",
|
||||||
domain=[('category', '=', Id('optical_equipment', 'uom_cat_frequency'))],
|
domain=[('category', '=', Id('optical_equipment', 'uom_cat_frequency'))],
|
||||||
states={'invisible' : If(Eval('frequency') == None, True)},
|
states={'invisible' : If(Eval('frequency') == None, True) |
|
||||||
|
~Eval('electrical_equipment', True)},
|
||||||
depends=['frequency']
|
depends=['frequency']
|
||||||
)
|
)
|
||||||
voltageAC = fields.Float("Voltage AC",
|
voltageAC = fields.Float("Voltage AC",
|
||||||
states={'invisible': ~Bool(Eval('electrical_equipment'))})
|
states={'invisible': ~Bool(Eval('electrical_equipment'))})
|
||||||
voltageAC_uom = fields.Many2One('product.uom', "Voltage AC UOM",
|
voltageAC_uom = fields.Many2One('product.uom', "Voltage AC UOM",
|
||||||
domain=[('category', '=', Id('optical_equipment', 'uom_cat_electrical_tension'))],
|
domain=[('category', '=', Id('optical_equipment', 'uom_cat_electrical_tension'))],
|
||||||
states={'invisible' : If(Eval('voltageAC') == None, True)},
|
states={'invisible' : If(Eval('voltageAC') == None, True) |
|
||||||
|
~Eval('electrical_equipment', True)},
|
||||||
depends=['voltageAC']
|
depends=['voltageAC']
|
||||||
)
|
)
|
||||||
voltageDC = fields.Float("Voltage DC",
|
voltageDC = fields.Float("Voltage DC",
|
||||||
states={'invisible': ~Bool(Eval('electrical_equipment'))})
|
states={'invisible': ~Bool(Eval('electrical_equipment'))})
|
||||||
voltageDC_uom = fields.Many2One('product.uom', "Voltage DC UOM",
|
voltageDC_uom = fields.Many2One('product.uom', "Voltage DC UOM",
|
||||||
domain=[('category', '=', Id('optical_equipment', 'uom_cat_electrical_tension'))],
|
domain=[('category', '=', Id('optical_equipment', 'uom_cat_electrical_tension'))],
|
||||||
states={'invisible' : If(Eval('voltageDC') == None, True)},
|
states={'invisible' : If(Eval('voltageDC') == None, True) |
|
||||||
|
~Eval('electrical_equipment', True)},
|
||||||
depends=['voltageDC'])
|
depends=['voltageDC'])
|
||||||
|
|
||||||
useful_life = fields.Integer("Useful life")
|
useful_life = fields.Integer("Useful life")
|
||||||
@ -165,6 +168,9 @@ class Template(metaclass=PoolMeta):
|
|||||||
analog_resolution = fields.Float("Analog resolution",
|
analog_resolution = fields.Float("Analog resolution",
|
||||||
states={'invisible': If(Eval('resolution_type') != 'analoga', True)},
|
states={'invisible': If(Eval('resolution_type') != 'analoga', True)},
|
||||||
depends=['resolution_type'])
|
depends=['resolution_type'])
|
||||||
|
a_factor_resolution = fields.Float("(a) Resolution",
|
||||||
|
states={'invisible': If(Eval('resolution_type') != 'analoga', True)},
|
||||||
|
depends=['resolution_type'])
|
||||||
Usubi = fields.Integer("Usub i")
|
Usubi = fields.Integer("Usub i")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -177,6 +183,16 @@ class Template(metaclass=PoolMeta):
|
|||||||
'invisible': ~Eval('calibration')},)
|
'invisible': ~Eval('calibration')},)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@fields.depends('temperature_min')
|
||||||
|
def default_temperature_min(self):
|
||||||
|
return 0
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@fields.depends('temperature_max')
|
||||||
|
def default_temperature_max(self):
|
||||||
|
return 0
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@fields.depends('temperature')
|
@fields.depends('temperature')
|
||||||
def default_temperature_uom(self):
|
def default_temperature_uom(self):
|
||||||
@ -186,6 +202,10 @@ class Template(metaclass=PoolMeta):
|
|||||||
|
|
||||||
return measurement
|
return measurement
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_frequency():
|
||||||
|
return 0
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_frequency_uom():
|
def default_frequency_uom():
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
@ -194,6 +214,14 @@ class Template(metaclass=PoolMeta):
|
|||||||
|
|
||||||
return measurement
|
return measurement
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_moisture_min():
|
||||||
|
return 0
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_moisture_max():
|
||||||
|
return 0
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_moisture_uom():
|
def default_moisture_uom():
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
@ -202,6 +230,10 @@ class Template(metaclass=PoolMeta):
|
|||||||
|
|
||||||
return measurement
|
return measurement
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_voltageAC():
|
||||||
|
return 0
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_voltageAC_uom():
|
def default_voltageAC_uom():
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
@ -210,6 +242,10 @@ class Template(metaclass=PoolMeta):
|
|||||||
|
|
||||||
return measurement
|
return measurement
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_voltageDC():
|
||||||
|
return 0
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_voltageDC_uom():
|
def default_voltageDC_uom():
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
@ -247,7 +283,14 @@ class Template(metaclass=PoolMeta):
|
|||||||
def default_refurbish():
|
def default_refurbish():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@fields.depends('d_resolution', 'analog_resolution', 'a_factor_resolution')
|
||||||
|
def on_change_resolution_type(self):
|
||||||
|
self.d_resolution = None
|
||||||
|
self.analog_resolution = None
|
||||||
|
self.a_factor_resolution = None
|
||||||
|
|
||||||
|
|
||||||
@fields.depends('equipment', 'replacement')
|
@fields.depends('equipment', 'replacement')
|
||||||
def on_change_equipment(self):
|
def on_change_equipment(self):
|
||||||
if self.equipment:
|
if self.equipment:
|
||||||
@ -269,9 +312,9 @@ class Template(metaclass=PoolMeta):
|
|||||||
@fields.depends('electrical_equipment')
|
@fields.depends('electrical_equipment')
|
||||||
def on_change_electrical_equipment(self):
|
def on_change_electrical_equipment(self):
|
||||||
if self.electrical_equipment:
|
if self.electrical_equipment:
|
||||||
self.voltageAC = None
|
self.voltageAC = 0
|
||||||
self.voltageDC = None
|
self.voltageDC = 0
|
||||||
self.frequency = None
|
self.frequency = 0
|
||||||
|
|
||||||
class Product(metaclass=PoolMeta):
|
class Product(metaclass=PoolMeta):
|
||||||
__name__ = 'product.product'
|
__name__ = 'product.product'
|
||||||
|
@ -4,6 +4,9 @@ from trytond.model import (
|
|||||||
from trytond.modules.company.model import set_employee
|
from trytond.modules.company.model import set_employee
|
||||||
from trytond.exceptions import UserError
|
from trytond.exceptions import UserError
|
||||||
|
|
||||||
|
from trytond.wizard import (
|
||||||
|
Button, StateAction, StateTransition, StateView, Wizard)
|
||||||
|
|
||||||
|
|
||||||
class Subscription(metaclass=PoolMeta):
|
class Subscription(metaclass=PoolMeta):
|
||||||
__name__ = 'sale.subscription'
|
__name__ = 'sale.subscription'
|
||||||
@ -38,7 +41,55 @@ class Subscription(metaclass=PoolMeta):
|
|||||||
equipment.save()
|
equipment.save()
|
||||||
Line.save(lines)
|
Line.save(lines)
|
||||||
cls.save(subscriptions)
|
cls.save(subscriptions)
|
||||||
|
|
||||||
|
|
||||||
|
class CreateContractInvoice(Wizard):
|
||||||
|
"Create Contract Invoice"
|
||||||
|
__name__ = 'sale.subscription.create_invoice_contract'
|
||||||
|
|
||||||
|
start = StateView(
|
||||||
|
'sale.subscription.create_invoice_contract.start',
|
||||||
|
'optical_equipment.create_invoice_contract_start_view_form',[
|
||||||
|
Button("Cancel", 'end', 'tryton-cancel'),
|
||||||
|
Button("Create", 'create_invoice', 'tryton-ok', default=True),
|
||||||
|
])
|
||||||
|
|
||||||
|
create_invoice = StateAction('account_invoice.act_invoice_form')
|
||||||
|
|
||||||
|
|
||||||
|
def do_create_invoice(self, action):
|
||||||
|
'Create and return an invoice'
|
||||||
|
raise UserError(str(dir(action)))
|
||||||
|
|
||||||
|
invoice_lines = []
|
||||||
|
for line in self.lines:
|
||||||
|
invoice_lines.append(line.get_invoice_line())
|
||||||
|
invoice_lines = list(chain(*invoice_lines))
|
||||||
|
|
||||||
|
if not invoice_lines:
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
invoice = self._get_invoice_sale()
|
||||||
|
if getattr(invoice, 'lines', None):
|
||||||
|
invoice_lines = list(invoice.lines) + invoice_lines
|
||||||
|
invoice.lines = invoice_lines
|
||||||
|
|
||||||
|
return invoice
|
||||||
|
|
||||||
|
class CreateContractInvoiceStart(ModelView):
|
||||||
|
"Create Subscription Invoice"
|
||||||
|
__name__ = 'sale.subscription.create_invoice_contract.start'
|
||||||
|
|
||||||
|
date = fields.Date("Date")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def default_date(cls):
|
||||||
|
pool = Pool()
|
||||||
|
Date = pool.get('ir.date')
|
||||||
|
|
||||||
|
return Date.today()
|
||||||
|
|
||||||
class SubscriptionEquipment(ModelSQL):
|
class SubscriptionEquipment(ModelSQL):
|
||||||
'Optical Equipment - Subscription'
|
'Optical Equipment - Subscription'
|
||||||
__name__ = 'sale.subscription-optical_equipment.equipment'
|
__name__ = 'sale.subscription-optical_equipment.equipment'
|
||||||
|
@ -7,9 +7,24 @@
|
|||||||
<field name="name">subscription_form</field>
|
<field name="name">subscription_form</field>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.ui.menu" id="sale_subscription.menu_line_consumption_create">
|
<record model="ir.ui.menu" id="sale_subscription.menu_line_consumption_create">
|
||||||
<field name="active" eval="False"/>
|
<field name="active" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.ui.menu" id="sale_subscription.menu_create_invoice">
|
<record model="ir.ui.menu" id="sale_subscription.menu_create_invoice">
|
||||||
<field name="active" eval="False"/>
|
<field name="active" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
<record model="ir.ui.view" id="create_invoice_contract_start_view_form">
|
||||||
|
<field name="model">sale.subscription.create_invoice_contract.start</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">create_invoice_contract_form</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.wizard" id="create_invoice_contract">
|
||||||
|
<field name="name">Invoice Contract</field>
|
||||||
|
<field name="wiz_name">sale.subscription.create_invoice_contract</field>
|
||||||
|
<field name="model">sale.subscription</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.keyword" id="create_invoice_contract_keyword">
|
||||||
|
<field name="keyword">form_action</field>
|
||||||
|
<field name="model">sale.subscription,-1</field>
|
||||||
|
<field name="action" ref="create_invoice_contract"/>
|
||||||
|
</record>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
@ -12,6 +12,7 @@ depends:
|
|||||||
country
|
country
|
||||||
sale_subscription
|
sale_subscription
|
||||||
account_stock_continental
|
account_stock_continental
|
||||||
|
account_invoice
|
||||||
xml:
|
xml:
|
||||||
address.xml
|
address.xml
|
||||||
party.xml
|
party.xml
|
||||||
|
@ -58,8 +58,10 @@
|
|||||||
<page string="Maintenances" id="maintenances_equipment">
|
<page string="Maintenances" id="maintenances_equipment">
|
||||||
<field name="maintenance_history"/>
|
<field name="maintenance_history"/>
|
||||||
</page>
|
</page>
|
||||||
|
<page string="Origins" id="origins_equipment">
|
||||||
|
<field name="purchase_origin"/>
|
||||||
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
|
|
||||||
<group col="2" colspan="2" id="button">
|
<group col="2" colspan="2" id="button">
|
||||||
<!--<button name="draft"/> -->
|
<!--<button name="draft"/> -->
|
||||||
<button name="registred"/>
|
<button name="registred"/>
|
||||||
|
@ -7,4 +7,8 @@
|
|||||||
<field name="equipments" colspan="4"/>
|
<field name="equipments" colspan="4"/>
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
|
<group col="2" colspan="2" id="button">
|
||||||
|
<button name="registred"/>
|
||||||
|
</group>
|
||||||
</data>
|
</data>
|
||||||
|
@ -62,6 +62,9 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<label name="d_resolution"/>
|
<label name="d_resolution"/>
|
||||||
<field name="d_resolution"/>
|
<field name="d_resolution"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
|
<label name="a_factor_resolution"/>
|
||||||
|
<field name="a_factor_resolution"/>
|
||||||
|
<newline/>
|
||||||
<label name="analog_resolution"/>
|
<label name="analog_resolution"/>
|
||||||
<field name="analog_resolution"/>
|
<field name="analog_resolution"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
|
Loading…
Reference in New Issue
Block a user