add model purchase
This commit is contained in:
parent
48ef146c44
commit
95e6ed60f3
@ -2,7 +2,8 @@
|
|||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
|
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from . import party, product, configuration, maintenance
|
from . import (party, product, purchase,
|
||||||
|
configuration, maintenance)
|
||||||
|
|
||||||
__all__ = ['register']
|
__all__ = ['register']
|
||||||
|
|
||||||
@ -15,7 +16,10 @@ def register():
|
|||||||
product.Template,
|
product.Template,
|
||||||
product.Product,
|
product.Product,
|
||||||
product.Pattern,
|
product.Pattern,
|
||||||
|
product.UsePattern,
|
||||||
product.Image,
|
product.Image,
|
||||||
|
purchase.Purchase,
|
||||||
|
purchase.Line,
|
||||||
maintenance.MaintenanceService,
|
maintenance.MaintenanceService,
|
||||||
maintenance.MaintenanceLine,
|
maintenance.MaintenanceLine,
|
||||||
module='optical_equipment', type_='model')
|
module='optical_equipment', type_='model')
|
||||||
|
9
configuration.py
Normal file
9
configuration.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from trytond.model import (
|
||||||
|
ModelSingleton, ModelSQL, ModelView, fields)
|
||||||
|
from trytond.pyson import Id
|
||||||
|
from trytond.modules.company.model import (
|
||||||
|
CompanyMultiValueMixin, CompanyValueMixin)
|
||||||
|
|
||||||
|
class Configuration(ModelSingleton, ModelSQL, ModelView, CompanyMultiValueMixin):
|
||||||
|
'Equipment Configuration'
|
||||||
|
__name__='optical_equipment.configuration'
|
23
configuration.xml
Normal file
23
configuration.xml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
this repository contains the full copyright notices and license terms. -->
|
||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
<record model="ir.action.act_window" id="act_optical_equipment_configuration_form">
|
||||||
|
<field name="name">Configuration</field>
|
||||||
|
<field name="res_model">optical_equipment.configuration</field>
|
||||||
|
</record>
|
||||||
|
<menuitem
|
||||||
|
name="Configuration"
|
||||||
|
parent="menu_equipment"
|
||||||
|
sequence="0"
|
||||||
|
id="menu_equipment_configuration"
|
||||||
|
icon="tryton-settings"/>
|
||||||
|
<menuitem
|
||||||
|
parent="menu_equipment_configuration"
|
||||||
|
action="act_optical_equipment_configuration_form"
|
||||||
|
sequence="10"
|
||||||
|
id="menu_optical_equipment_configuration"
|
||||||
|
icon="tryton-list"/>
|
||||||
|
</data>
|
||||||
|
</tryton>
|
11
equipment.xml
Normal file
11
equipment.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
this repository contains the full copyright notices and license terms. -->
|
||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
<menuitem
|
||||||
|
name="Equipment"
|
||||||
|
sequence="40"
|
||||||
|
id="menu_equipment"/>
|
||||||
|
</data>
|
||||||
|
</tryton>
|
69
product.py
69
product.py
@ -41,37 +41,32 @@ NON_MEASURABLE = ['service']
|
|||||||
class Template(metaclass=PoolMeta):
|
class Template(metaclass=PoolMeta):
|
||||||
'Template'
|
'Template'
|
||||||
__name__ = 'product.template'
|
__name__ = 'product.template'
|
||||||
|
|
||||||
|
|
||||||
product = fields.Many2One('optical_equipment.maintenance', "Maintenance Activity",
|
product = fields.Many2One('optical_equipment.maintenance', "Maintenance Activity",
|
||||||
ondelete='CASCADE', select=True)
|
ondelete='CASCADE', select=True)
|
||||||
equipment = fields.Boolean('It is equipment',
|
equipment = fields.Boolean('It is equipment',
|
||||||
states={'invisible': Eval('type', 'goods') != 'goods',
|
states={'invisible': Eval('type', 'goods') != 'goods',
|
||||||
},depends=['type']
|
})
|
||||||
)
|
|
||||||
maintenance_activity = fields.Boolean('Maintenance Activity',
|
maintenance_activity = fields.Boolean('Maintenance Activity',
|
||||||
states={'invisible': Eval('type', 'service') != 'service',
|
states={'invisible': Eval('type', 'service') != 'service',
|
||||||
'readonly': If(Eval('equipment',True), True)
|
'readonly': If(Eval('equipment',True), True)
|
||||||
| If(Eval('replacement',True), True)
|
| If(Eval('replacement',True), True)
|
||||||
},depends=['type'])
|
})
|
||||||
replacement = fields.Boolean('Replacement',
|
replacement = fields.Boolean('Replacement',
|
||||||
states={'invisible': Eval('type', 'goods') != 'goods',
|
states={'invisible': Eval('type', 'goods') != 'goods',
|
||||||
'readonly': If(Eval('equipment',True), True)
|
'readonly': If(Eval('equipment',True), True)
|
||||||
| If(Eval('maintenance_activity',True), True)
|
| If(Eval('maintenance_activity',True), True)
|
||||||
},depends=['type'])
|
})
|
||||||
equipment_type = fields.Selection(_EQUIPMENT_TYPE, 'Equipment type',
|
equipment_type = fields.Selection(_EQUIPMENT_TYPE, 'Equipment type',
|
||||||
states={'required': Eval('equipment', False)},
|
states={'required': Eval('equipment', False)})
|
||||||
depends=['equipment'])
|
|
||||||
risk = fields.Selection(_RISK, 'Type risk')
|
risk = fields.Selection(_RISK, 'Type risk')
|
||||||
use = fields.Selection(_USE, 'Use',
|
use = fields.Selection(_USE, 'Use',
|
||||||
states={'required': Eval('equipment', False)},
|
states={'required': Eval('equipment', False)},
|
||||||
depends=['equipment'])
|
depends={'equipment'})
|
||||||
biomedical_class = fields.Selection(_BIOMEDICAL_CLASS,'Biomedical Class',
|
biomedical_class = fields.Selection(_BIOMEDICAL_CLASS,'Biomedical Class',
|
||||||
states={'required': Eval('equipment', False)},
|
states={'required': Eval('equipment', False)})
|
||||||
depends=['equipment'])
|
|
||||||
main_tecnology = fields.Selection(_MAIN_TECNOLOGY,'Main tecnology',
|
main_tecnology = fields.Selection(_MAIN_TECNOLOGY,'Main tecnology',
|
||||||
states={'required': Eval('equipment', False)},
|
states={'required': Eval('equipment', False)})
|
||||||
depends=['equipment'])
|
|
||||||
calibration = fields.Boolean("Apply calibration")
|
calibration = fields.Boolean("Apply calibration")
|
||||||
observation = fields.Text('Observation')
|
observation = fields.Text('Observation')
|
||||||
|
|
||||||
@ -79,13 +74,11 @@ class Template(metaclass=PoolMeta):
|
|||||||
mark_category = fields.Many2One('product.category', 'Mark',
|
mark_category = fields.Many2One('product.category', 'Mark',
|
||||||
domain=[('parent', '=', None),
|
domain=[('parent', '=', None),
|
||||||
('accounting', '=', False)],
|
('accounting', '=', False)],
|
||||||
states={'required': Eval('equipment', False)},
|
states={'required': Eval('equipment', False)})
|
||||||
depends=['equipment'])
|
|
||||||
model_category = fields.Many2One('product.category', "Model",
|
model_category = fields.Many2One('product.category', "Model",
|
||||||
domain=[('parent', '=', Eval('mark_category')),
|
domain=[('parent', '=', Eval('mark_category')),
|
||||||
('accounting', '=', False)],
|
('accounting', '=', False)],
|
||||||
states={'required': Eval('equipment', False)},
|
states={'required': Eval('equipment', False)})
|
||||||
depends=['equipment'])
|
|
||||||
reference_category = fields.Many2One('product.category', "Reference",
|
reference_category = fields.Many2One('product.category', "Reference",
|
||||||
domain=[('parent', '=', Eval('model_category'))],)
|
domain=[('parent', '=', Eval('model_category'))],)
|
||||||
|
|
||||||
@ -95,7 +88,7 @@ class Template(metaclass=PoolMeta):
|
|||||||
software_required = fields.Boolean("Software Required")
|
software_required = fields.Boolean("Software Required")
|
||||||
software_version = fields.Char("Software version",
|
software_version = fields.Char("Software version",
|
||||||
states={'invisible': If(~Eval('software_required'), True)},
|
states={'invisible': If(~Eval('software_required'), True)},
|
||||||
depends=['software_required'])
|
depends={'software_required'})
|
||||||
|
|
||||||
#These are measurements required for the equipments, are in this place
|
#These are measurements required for the equipments, are in this place
|
||||||
# for manage of class 'product.template'
|
# for manage of class 'product.template'
|
||||||
@ -104,21 +97,17 @@ class Template(metaclass=PoolMeta):
|
|||||||
temperature_max = fields.Float("Temp Max")
|
temperature_max = fields.Float("Temp Max")
|
||||||
temperature_uom = fields.Many2One('product.uom', 'Temperature UOM',
|
temperature_uom = fields.Many2One('product.uom', 'Temperature UOM',
|
||||||
domain=[('category', '=', Id('optical_equipment', "uom_cat_temperature"))],
|
domain=[('category', '=', Id('optical_equipment', "uom_cat_temperature"))],
|
||||||
states={'invisible' : If(Eval('temperature_min') == None, True)},
|
states={'invisible' : If(Eval('temperature_min') == None, True)})
|
||||||
depends=['itemperature_min']
|
|
||||||
)
|
|
||||||
frequency = fields.Float("Frequency")
|
frequency = fields.Float("Frequency")
|
||||||
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)}
|
||||||
depends=['frequency']
|
|
||||||
)
|
)
|
||||||
moisture_min = fields.Float("Moisture Min")
|
moisture_min = fields.Float("Moisture Min")
|
||||||
moisture_max = fields.Float("Moisture Max")
|
moisture_max = fields.Float("Moisture Max")
|
||||||
moisture_uom = fields.Many2One('product.uom', "Moisture UOM",
|
moisture_uom = fields.Many2One('product.uom', "Moisture UOM",
|
||||||
domain=[('category', '=', Id('optical_equipment', 'uom_cat_relative_humedity'))],
|
domain=[('category', '=', Id('optical_equipment', 'uom_cat_relative_humedity'))],
|
||||||
states={'invisible' : If(Eval('moisture_min') == None, True)},
|
states={'invisible' : If(Eval('moisture_min') == None, True)},
|
||||||
depends=['moisture_min']
|
|
||||||
)
|
)
|
||||||
electrical_equipment = fields.Boolean("Electrical Equipment")
|
electrical_equipment = fields.Boolean("Electrical Equipment")
|
||||||
frequency = fields.Float("Frequency",
|
frequency = fields.Float("Frequency",
|
||||||
@ -127,7 +116,6 @@ class Template(metaclass=PoolMeta):
|
|||||||
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)},
|
~Eval('electrical_equipment', True)},
|
||||||
depends=['frequency']
|
|
||||||
)
|
)
|
||||||
voltageAC = fields.Float("Voltage AC",
|
voltageAC = fields.Float("Voltage AC",
|
||||||
states={'invisible': ~Bool(Eval('electrical_equipment'))})
|
states={'invisible': ~Bool(Eval('electrical_equipment'))})
|
||||||
@ -135,20 +123,26 @@ class Template(metaclass=PoolMeta):
|
|||||||
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)},
|
~Eval('electrical_equipment', True)},
|
||||||
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)},
|
~Eval('electrical_equipment', True)},)
|
||||||
depends=['voltageDC'])
|
|
||||||
|
|
||||||
useful_life = fields.Integer("Useful life")
|
useful_life = fields.Integer("Useful life")
|
||||||
warranty = fields.Integer("Warranty")
|
warranty = fields.Integer("Warranty")
|
||||||
|
|
||||||
#### calibration parameters
|
#### calibration parameters
|
||||||
|
use_pattern = fields.Many2One('optical_equipment.use_pattern', "Use Pattern", ondelete='RESTRICT',
|
||||||
|
states={'required': Eval('calibration', True)})
|
||||||
|
#use_pattern = fields.Selection([
|
||||||
|
# ('', ""),
|
||||||
|
# ('ojo_esquematico', "Ojo esquematico"),
|
||||||
|
# ('lente_prueba', "Lente de Prueba"),
|
||||||
|
# ('pesas_calibration', "Pesas de Calibración"),
|
||||||
|
# ('esferas_calibration', "Esferas de Calibración")], "Patrón Utilizado", states={'required': Eval('calibration', True)})
|
||||||
measuring_range = fields.Selection([
|
measuring_range = fields.Selection([
|
||||||
('dioptria', "Dioptria"),
|
('dioptria', "Dioptria"),
|
||||||
('mmhg', "mmHg")], "Rango de Medición")
|
('mmhg', "mmHg")], "Rango de Medición")
|
||||||
@ -162,17 +156,13 @@ class Template(metaclass=PoolMeta):
|
|||||||
resolution_type = fields.Selection([('',""),
|
resolution_type = fields.Selection([('',""),
|
||||||
('analoga', "Analoga"),
|
('analoga', "Analoga"),
|
||||||
('digital', "Digital")], "Resolution Type",
|
('digital', "Digital")], "Resolution Type",
|
||||||
states={'required': Eval('calibration', False)},
|
states={'required': Eval('calibration', False)},)
|
||||||
depends=['calibration'])
|
|
||||||
d_resolution = fields.Float("Resolution d",
|
d_resolution = fields.Float("Resolution d",
|
||||||
states={'invisible': If(Eval('resolution_type') != 'digital', True)},
|
states={'invisible': If(Eval('resolution_type') != 'digital', True)},)
|
||||||
depends=['resolution_type'])
|
|
||||||
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'])
|
|
||||||
a_factor_resolution = fields.Float("(a) Resolution",
|
a_factor_resolution = fields.Float("(a) Resolution",
|
||||||
states={'invisible': If(Eval('resolution_type') != 'analoga', True)},
|
states={'invisible': If(Eval('resolution_type') != 'analoga', True)},)
|
||||||
depends=['resolution_type'])
|
|
||||||
Usubi = fields.Integer("Usub i",states={'required': Eval('calibration', False)},)
|
Usubi = fields.Integer("Usub i",states={'required': Eval('calibration', False)},)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -382,7 +372,14 @@ class Image(metaclass=PoolMeta):
|
|||||||
default.setdefault('product', None)
|
default.setdefault('product', None)
|
||||||
return super().copy(images, default=default)
|
return super().copy(images, default=default)
|
||||||
|
|
||||||
|
|
||||||
|
class UsePattern(ModelSQL,ModelView):
|
||||||
|
"Use Pattern"
|
||||||
|
__name__ = 'optical_equipment.use_pattern'
|
||||||
|
_rec_name = 'name_pattern'
|
||||||
|
|
||||||
|
name_pattern = fields.Char('Name Pattern', required=True)
|
||||||
|
|
||||||
class Pattern(ModelSQL, ModelView):
|
class Pattern(ModelSQL, ModelView):
|
||||||
"Pattern K of equipment"
|
"Pattern K of equipment"
|
||||||
__name__ = 'optical_equipment.product_pattern'
|
__name__ = 'optical_equipment.product_pattern'
|
||||||
|
51
product.xml
51
product.xml
@ -3,6 +3,43 @@
|
|||||||
this repository contains the full copyright notices and license terms. -->
|
this repository contains the full copyright notices and license terms. -->
|
||||||
<tryton>
|
<tryton>
|
||||||
<data>
|
<data>
|
||||||
|
<record model="ir.action.act_window" id="act_use_pattern">
|
||||||
|
<field name="name">Use Pattern</field>
|
||||||
|
<field name="res_model">optical_equipment.use_pattern</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.ui.view" id="use_pattern_view_tree">
|
||||||
|
<field name="model">optical_equipment.use_pattern</field>
|
||||||
|
<field name="type">tree</field>
|
||||||
|
<field name="name">use_pattern_tree</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.ui.view" id="use_pattern_view_form">
|
||||||
|
<field name="model">optical_equipment.use_pattern</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">use_pattern_form</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.view" id="act_use_pattern_view1">
|
||||||
|
<field name="sequence" eval="10"/>
|
||||||
|
<field name="view" ref="use_pattern_view_tree"/>
|
||||||
|
<field name="act_window" ref="act_use_pattern"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.view" id="act_use_pattern_view2">
|
||||||
|
<field name="sequence" eval="20"/>
|
||||||
|
<field name="view" ref="use_pattern_view_form"/>
|
||||||
|
<field name="act_window" ref="act_use_pattern"/>
|
||||||
|
</record>
|
||||||
|
<menuitem
|
||||||
|
name="Properties of Equipments"
|
||||||
|
parent="product.menu_configuration"
|
||||||
|
sequence="10"
|
||||||
|
id="menu_properties_equipments"
|
||||||
|
icon="tryton-settings"/>
|
||||||
|
<menuitem
|
||||||
|
parent="menu_properties_equipments"
|
||||||
|
name="Pattern Use"
|
||||||
|
action="act_use_pattern"
|
||||||
|
sequence="10"
|
||||||
|
id="menu_pattern"
|
||||||
|
icon="tryton-list"/>
|
||||||
<record model="ir.ui.view" id="template_view_form1">
|
<record model="ir.ui.view" id="template_view_form1">
|
||||||
<field name="model">product.template</field>
|
<field name="model">product.template</field>
|
||||||
<field name="inherit" ref="product.template_view_form"/>
|
<field name="inherit" ref="product.template_view_form"/>
|
||||||
@ -23,5 +60,19 @@
|
|||||||
<field name="type">tree</field>
|
<field name="type">tree</field>
|
||||||
<field name="name">pattern_tree</field>
|
<field name="name">pattern_tree</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!--Patterns use-->
|
||||||
|
<record model="optical_equipment.use_pattern" id="schematic_eye">
|
||||||
|
<field name="name_pattern">Schematic Eye</field>
|
||||||
|
</record>
|
||||||
|
<record model="optical_equipment.use_pattern" id="trial_lens">
|
||||||
|
<field name="name_pattern">Trial Lens</field>
|
||||||
|
</record>
|
||||||
|
<record model="optical_equipment.use_pattern" id="calibration_weights">
|
||||||
|
<field name="name_pattern">Calibration Weights</field>
|
||||||
|
</record>
|
||||||
|
<record model="optical_equipment.use_pattern" id="calibration_spheres">
|
||||||
|
<field name="name_pattern">Calibration Spheres</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
190
purchase.py
Normal file
190
purchase.py
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
#This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
#txhis repository contains the full copyright notices and license terms
|
||||||
|
from trytond.pool import Pool, PoolMeta
|
||||||
|
from trytond.model import (
|
||||||
|
ModelView, ModelSQL, Workflow, fields)
|
||||||
|
from trytond.modules.product import price_digits, round_price
|
||||||
|
from trytond.pyson import Eval, If, Bool
|
||||||
|
from trytond.exceptions import UserError
|
||||||
|
from trytond.i18n import gettext
|
||||||
|
from trytond.transaction import Transaction
|
||||||
|
|
||||||
|
|
||||||
|
class Purchase(metaclass=PoolMeta):
|
||||||
|
"Purchase Equipment"
|
||||||
|
__name__ = 'purchase.purchase'
|
||||||
|
|
||||||
|
equipment_create = fields.Boolean("Equipments Creates", readonly=True)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def __setup__(cls):
|
||||||
|
super(Purchase, cls).__setup__()
|
||||||
|
cls._buttons.update({
|
||||||
|
'create_equipments': {
|
||||||
|
'invisible': If(Eval('invoice_state') == 'none', True) |
|
||||||
|
If(Bool(Eval('equipment_create')), True),
|
||||||
|
'depends': ['invoice_state'],}})
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def copy(cls, purchases, default=None):
|
||||||
|
if default is None:
|
||||||
|
default = {}
|
||||||
|
else:
|
||||||
|
default = default.copy()
|
||||||
|
|
||||||
|
default.setdefault('number', None)
|
||||||
|
default.setdefault('invoice_state', 'none')
|
||||||
|
default.setdefault('invoices_ignored', None)
|
||||||
|
default.setdefault('moves', None)
|
||||||
|
default.setdefault('shipment_state', 'none')
|
||||||
|
default.setdefault('purchase_date', None)
|
||||||
|
default.setdefault('quoted_by')
|
||||||
|
default.setdefault('confirmed_by')
|
||||||
|
default.setdefault('equipment_create', None)
|
||||||
|
|
||||||
|
return super(Purchase, cls).copy(purchases, default=default)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@ModelView.button
|
||||||
|
def create_equipments(cls, purchases):
|
||||||
|
if len(purchases) == 1:
|
||||||
|
pool = Pool()
|
||||||
|
Equipment = pool.get('optical_equipment.equipment')
|
||||||
|
Config = pool.get('optical_equipment.configuration')
|
||||||
|
config = Config(1)
|
||||||
|
|
||||||
|
purchase = purchases[0]
|
||||||
|
|
||||||
|
for line in purchase.lines:
|
||||||
|
if line.product.equipment:
|
||||||
|
for i in range(0,int(line.quantity)):
|
||||||
|
equipment = Equipment(
|
||||||
|
company=line.company,
|
||||||
|
location=line.to_location,
|
||||||
|
equipment_type=line.product.equipment_type,
|
||||||
|
propietary=line.company.party,
|
||||||
|
propietary_address=line.address_equipment,
|
||||||
|
product=line.product,
|
||||||
|
model_category=line.product.model_category,
|
||||||
|
mark_category=line.product.mark_category,
|
||||||
|
reference_category=line.product.reference_category,
|
||||||
|
useful_life=line.product.useful_life if line.product.useful_life else 0,
|
||||||
|
calibration=True if line.product.calibration else False,
|
||||||
|
warranty=line.product.warranty if line.product.warranty else 0,
|
||||||
|
risk=line.product.risk,
|
||||||
|
origin_country=line.product.origin_country,
|
||||||
|
use=line.product.use,
|
||||||
|
biomedical_class=line.product.biomedical_class,
|
||||||
|
refurbish=line.refurbish,
|
||||||
|
serial=None if line.quantity > 1 else line.serial_equipment,
|
||||||
|
health_register=line.health_register,
|
||||||
|
software_version=line.product.software_version if line.product.software_required else "No Aplica",
|
||||||
|
maintenance_frequency="none",
|
||||||
|
purchase_origin=line,
|
||||||
|
)
|
||||||
|
equipment.save()
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
purchase.equipment_create = True
|
||||||
|
cls.save(purchases)
|
||||||
|
else:
|
||||||
|
raise UserError(str("Número de Compras Invalido."))
|
||||||
|
|
||||||
|
|
||||||
|
class Line(metaclass=PoolMeta):
|
||||||
|
"Purchase Line Equipment"
|
||||||
|
__name__ = 'purchase.line'
|
||||||
|
|
||||||
|
origin_country = fields.Many2One('country.country',"Origin Country")
|
||||||
|
address_equipment = fields.Many2One('party.address', "Direccion", required=True)
|
||||||
|
serial_equipment = fields.Char("Serial", size=None,
|
||||||
|
states={'invisible': If(Eval('quantity') > 1, True)})
|
||||||
|
refurbish = fields.Boolean("Refurbish")
|
||||||
|
product_equipment = fields.Boolean("Product Equipment",
|
||||||
|
states={'readonly': True})
|
||||||
|
software_version = fields.Char("Software version")
|
||||||
|
health_register = fields.Char("Health Register", states={'required': Eval('product_equipment', True)})
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def default_address_equipment(cls):
|
||||||
|
pool = Pool()
|
||||||
|
Company = pool.get('company.company')
|
||||||
|
company = Transaction().context.get('company')
|
||||||
|
if company:
|
||||||
|
company = Company(company)
|
||||||
|
|
||||||
|
return company.party.addresses[0].id
|
||||||
|
|
||||||
|
@fields.depends(
|
||||||
|
'product', 'quantity', methods=['_get_context_purchase_price'])
|
||||||
|
def on_change_quantity(self):
|
||||||
|
Product = Pool().get('product.product')
|
||||||
|
if self.quantity > 1 or self.quantity < 1:
|
||||||
|
self.serial_equipment = None
|
||||||
|
|
||||||
|
if not self.product:
|
||||||
|
self.serial_equipment = None
|
||||||
|
return
|
||||||
|
|
||||||
|
with Transaction().set_context(self._get_context_purchase_price()):
|
||||||
|
self.unit_price = Product.get_purchase_price([self.product],
|
||||||
|
abs(self.quantity or 0))[self.product.id]
|
||||||
|
|
||||||
|
if self.unit_price:
|
||||||
|
self.unit_price = round_price(self.unit_price)
|
||||||
|
|
||||||
|
@fields.depends('product', 'unit', 'purchase', '_parent_purchase.party',
|
||||||
|
'_parent_purchase.invoice_party', 'product_supplier', 'product_equipment',
|
||||||
|
'serial_equipment', 'software_version', 'health_register',
|
||||||
|
'refurbish', methods=['compute_taxes', 'compute_unit_price',
|
||||||
|
'_get_product_supplier_pattern'])
|
||||||
|
def on_change_product(self):
|
||||||
|
if not self.product:
|
||||||
|
self.product_equipment = False
|
||||||
|
self.address_equipment = None
|
||||||
|
self.serial_equipment = None
|
||||||
|
self.software_version = None
|
||||||
|
self.health_register = None
|
||||||
|
self.refurbish = None
|
||||||
|
self.quantity = None
|
||||||
|
self.unit_price = None
|
||||||
|
self.unit = None
|
||||||
|
|
||||||
|
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()
|
||||||
|
if self.product.equipment:
|
||||||
|
self.product_equipment = True
|
||||||
|
self.address_equipment = self.default_address_equipment()
|
||||||
|
if self.product.software_required:
|
||||||
|
self.software_version = self.product.software_version
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def view_attributes(cls):
|
||||||
|
return super(Line, cls).view_attributes() + [
|
||||||
|
('//page[@id="equipment"]', 'states', {
|
||||||
|
'invisible': ~Eval('product_equipment', True),
|
||||||
|
})]
|
42
purchase.xml
Normal file
42
purchase.xml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
this repository contains the full copyright notices and license terms. -->
|
||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
<record model="ir.ui.view" id="purchase_view_form">
|
||||||
|
<field name="model">purchase.purchase</field>
|
||||||
|
<field name="inherit" ref="purchase.purchase_view_form"/>
|
||||||
|
<field name="name">purchase_form</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.ui.view" id="purchase_line_view_form">
|
||||||
|
<field name="model">purchase.line</field>
|
||||||
|
<field name="inherit" ref="purchase.purchase_line_view_form"/>
|
||||||
|
<field name="name">purchase_line_form</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.ui.view" id="product_view_list_purchase_line">
|
||||||
|
<field name="model">product.product</field>
|
||||||
|
<field name="inherit" ref="purchase.product_view_list_purchase_line"/>
|
||||||
|
<field name="name">product_list_purchase_line</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.model.button" id="purchase_create_equipments">
|
||||||
|
<field name="name">create_equipments</field>
|
||||||
|
<field name="string">Create Equipments</field>
|
||||||
|
<field name="model" search="[('model', '=', 'purchase.purchase')]"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.report" id="purchase.report_purchase">
|
||||||
|
<field name="active">False</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.report" id="report_purchase">
|
||||||
|
<field name="name">Purchase</field>
|
||||||
|
<field name="model">purchase.purchase</field>
|
||||||
|
<field name="report_name">purchase.purchase</field>
|
||||||
|
<field name="report">optical_equipment/report/Purchase.fodt</field>
|
||||||
|
<field name="single" eval="True"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.keyword" id="report_purchase_keyword">
|
||||||
|
<field name="keyword">form_print</field>
|
||||||
|
<field name="model">purchase.purchase,-1</field>
|
||||||
|
<field name="action" ref="report_purchase"/>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</tryton>
|
@ -3,13 +3,17 @@ version=6.4
|
|||||||
depends:
|
depends:
|
||||||
ir
|
ir
|
||||||
company
|
company
|
||||||
|
account_product
|
||||||
party
|
party
|
||||||
product
|
product
|
||||||
|
product_attribute
|
||||||
product_image
|
product_image
|
||||||
product_measurements
|
product_measurements
|
||||||
|
purchase
|
||||||
xml:
|
xml:
|
||||||
configuration.xml
|
|
||||||
equipment.xml
|
equipment.xml
|
||||||
|
configuration.xml
|
||||||
party.xml
|
party.xml
|
||||||
uom.xml
|
uom.xml
|
||||||
product.xml
|
product.xml
|
||||||
|
purchase.xml
|
||||||
|
7
view/pattern_form.xml
Normal file
7
view/pattern_form.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
this repository contains the full copyright notices and license terms. -->
|
||||||
|
<form>
|
||||||
|
<label name="pattern"/>
|
||||||
|
<field name="pattern"/>
|
||||||
|
</form>
|
6
view/pattern_tree.xml
Normal file
6
view/pattern_tree.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
this repository contains the full copyright notices and license terms. -->
|
||||||
|
<tree>
|
||||||
|
<field name="pattern"/>
|
||||||
|
</tree>
|
12
view/purchase_form.xml
Normal file
12
view/purchase_form.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--This file file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||||
|
<data>
|
||||||
|
<xpath
|
||||||
|
expr="/form/field[@name='invoice_address']" position="after">
|
||||||
|
<label name="equipment_create"/>
|
||||||
|
<field name="equipment_create"/>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//button[@name='process']" position="after">
|
||||||
|
<button name="create_equipments"/>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
28
view/purchase_line_form.xml
Normal file
28
view/purchase_line_form.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--This file file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||||
|
<data>
|
||||||
|
<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="software_version"/>
|
||||||
|
<field name="software_version"/>
|
||||||
|
<newline/>
|
||||||
|
<label name="health_register"/>
|
||||||
|
<field name="health_register"/>
|
||||||
|
<newline/>
|
||||||
|
<label name="refurbish"/>
|
||||||
|
<field name="refurbish"/>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
|
<xpath
|
||||||
|
expr="/form/notebook/page[@id='general']/field[@name='product']" position="after">
|
||||||
|
<label name="product_equipment"/>
|
||||||
|
<field name="product_equipment"/>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
8
view/purchase_list_purchase_lone.xml
Normal file
8
view/purchase_list_purchase_lone.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
this repository contains the full copyright notices and license terms. -->
|
||||||
|
<data>
|
||||||
|
<xpath expr="//field[@name='name']" position="after">
|
||||||
|
<field name="attributes_name" expand="1"/>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
@ -11,7 +11,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<field name="maintenance_activity"/>
|
<field name="maintenance_activity"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="/form/notebook/page[@id='general']" position="after">
|
<xpath expr="/form/notebook/page[@id='general']" position="after">
|
||||||
<page string="Features" id="features" col="-1">
|
<page string="Features" id="features" col="4">
|
||||||
<newline/>
|
<newline/>
|
||||||
<label name="mark_category"/>
|
<label name="mark_category"/>
|
||||||
<field name="mark_category"/>
|
<field name="mark_category"/>
|
||||||
@ -52,7 +52,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<label name="warranty" string="Months"/>
|
<label name="warranty" string="Months"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<label name="observation"/>
|
<label name="observation"/>
|
||||||
<field name="observation"/>
|
<field name="observation" xexpand="1"/>
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="/form/notebook/page[@id='features']" position="after">
|
<xpath expr="/form/notebook/page[@id='features']" position="after">
|
||||||
@ -67,6 +67,9 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<label name="k_pattern"/>
|
<label name="k_pattern"/>
|
||||||
<field name="k_pattern"/>
|
<field name="k_pattern"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
|
<label name="use_pattern"/>
|
||||||
|
<field name="use_pattern"/>
|
||||||
|
<newline/>
|
||||||
<label name="k_pattern_list"/>
|
<label name="k_pattern_list"/>
|
||||||
<field name="k_pattern_list"/>
|
<field name="k_pattern_list"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
|
7
view/use_pattern_form.xml
Normal file
7
view/use_pattern_form.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
this repository contains the full copyright notices and license terms. -->
|
||||||
|
<form>
|
||||||
|
<label name="name_pattern"/>
|
||||||
|
<field name="name_pattern"/>
|
||||||
|
</form>
|
6
view/use_pattern_tree.xml
Normal file
6
view/use_pattern_tree.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
this repository contains the full copyright notices and license terms. -->
|
||||||
|
<tree editable="1">
|
||||||
|
<field name="name_pattern" expand="1"/>
|
||||||
|
</tree>
|
Loading…
Reference in New Issue
Block a user