sequence draft serial, add multiple equipments

This commit is contained in:
sinergia 2022-07-21 02:47:05 -05:00
parent f08e0a0f83
commit c056bbc38a
6 changed files with 48 additions and 43 deletions

View File

@ -8,4 +8,9 @@ class Configuration(ModelSingleton, ModelSQL, ModelView):
equipment_sequence = fields.Many2One('ir.sequence', "Equipment Sequence", equipment_sequence = fields.Many2One('ir.sequence', "Equipment Sequence",
domain=[('sequence_type', '=', Id('optical_equipment', 'sequence_type_equipment')) domain=[('sequence_type', '=', Id('optical_equipment', 'sequence_type_equipment'))
]) ]
)
serial_draft_sequence = fields.Many2One('ir.sequence', "Serial Draft",
domain=[('sequence_type', '=', Id('optical_equipment', 'sequence_type_equipment'))]
)

View File

@ -110,5 +110,11 @@
<field name="name">Equipment</field> <field name="name">Equipment</field>
<field name="sequence_type" ref="sequence_type_equipment"/> <field name="sequence_type" ref="sequence_type_equipment"/>
</record> </record>
<record model="ir.sequence" id="sequence_serial_draft">
<field name="name">Draft Serial</field>
<field name="prefix">SMRTS-</field>
<field name="padding">6</field>
<field name="sequence_type" ref="sequence_type_equipment"/>
</record>
</data> </data>
</tryton> </tryton>

16
es.po
View File

@ -1,16 +0,0 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.template,equipment:"
msgid "It is equipment"
msgstr "Es equipo
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.template,type_coffee:"
msgid "Type Coffee"
msgstr "Tipo Café"

View File

@ -1,8 +1,5 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of #This file is part of Tryton. The COPYRIGHT file at the top level of
#txhis repository contains the full copyright notices and license terms #txhis repository contains the full copyright notices and license terms
from sql import Literal
from sql.operators import Equal
from trytond.pool import Pool, PoolMeta from trytond.pool import Pool, PoolMeta
from trytond.model import ( from trytond.model import (
ModelView, ModelSQL, fields, Exclude) ModelView, ModelSQL, fields, Exclude)
@ -207,6 +204,11 @@ class Template(metaclass=PoolMeta):
def default_refurbish(): def default_refurbish():
return False return False
@fields.depends('equipment', 'replacement')
def on_change_equipment(self):
if self.equipment:
self.replacement=False
self.maintenance_activity=False
@fields.depends('mark_category', 'model_category', 'reference_category') @fields.depends('mark_category', 'model_category', 'reference_category')
def on_change_mark_category(self): def on_change_mark_category(self):

View File

@ -32,10 +32,14 @@ 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')
Config = pool.get('optical_equipment.configuration')
config = Config(1)
purchase = purchases[0] purchase = purchases[0]
for line in purchase.lines: for line in purchase.lines:
if line.product.equipment: if line.product.equipment:
for i in range(0,int(line.quantity)):
equipment = Equipment( equipment = Equipment(
company=line.company, company=line.company,
location=line.to_location, location=line.to_location,
@ -54,7 +58,7 @@ class Purchase(metaclass=PoolMeta):
use=line.product.use, use=line.product.use,
biomedical_class=line.product.biomedical_class, biomedical_class=line.product.biomedical_class,
refurbish=line.refurbish, refurbish=line.refurbish,
serial=line.serial_equipment, serial=config.serial_draft_sequence.get() if line.quantity > 1 else line.serial_equipment,
health_register=line.health_register, health_register=line.health_register,
software_version=line.software_version) software_version=line.software_version)
equipment.save() equipment.save()
@ -72,7 +76,9 @@ class Line(metaclass=PoolMeta):
origin_country = origin_country = fields.Many2One('country.country',"Origin Country") origin_country = origin_country = fields.Many2One('country.country',"Origin Country")
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,
states={'invisible': If(Eval('quantity') > 1, True),
},depends=['quantity'])
refurbish = fields.Boolean("Refurbish") refurbish = fields.Boolean("Refurbish")
product_equipment = fields.Boolean("Product Equipment", product_equipment = fields.Boolean("Product Equipment",
states={'readonly': True}) states={'readonly': True})

View File

@ -6,5 +6,7 @@ this repository contains the full copyright notices and license terms. -->
<separator id="sequences" string="Sequences" colspan="4"/> <separator id="sequences" string="Sequences" colspan="4"/>
<label name="equipment_sequence"/> <label name="equipment_sequence"/>
<field name="equipment_sequence"/> <field name="equipment_sequence"/>
<label name="serial_draft_sequence"/>
<field name="serial_draft_sequence"/>
</form> </form>