Changed wizard in order to allow search several picking lists at a time

This commit is contained in:
jmartin 2014-12-04 12:33:45 +01:00
parent 8548590dad
commit a7b99be470
5 changed files with 39 additions and 11 deletions

View File

@ -4,9 +4,11 @@
from trytond.pool import Pool
from .shipment import *
def register():
Pool.register(
StockSearchShipmentStart,
StockSearchShipmentStartFields,
module='stock_search_shipment', type_='model')
Pool.register(
StockSearchShipment,

View File

@ -3,17 +3,27 @@
# copyright notices and license terms.
from trytond.model import fields, ModelView
from trytond.pool import Pool, PoolMeta
from trytond.wizard import Button, StateAction, StateView, Wizard
from trytond.wizard import Button, StateAction, StateTransition, StateView, \
Wizard
from trytond.pyson import PYSONEncoder
from trytond.transaction import Transaction
__all__ = ['StockSearchShipmentStart', 'StockSearchShipment']
__all__ = ['StockSearchShipmentStart', 'StockSearchShipmentStartFields',
'StockSearchShipment']
__metaclass__ = PoolMeta
class StockSearchShipmentStart(ModelView):
'Stock Search Shipment Start'
__name__ = 'stock.search.shipment.start'
shipments = fields.One2Many('stock.search.shipment.start.field', 'search',
'Shipments')
class StockSearchShipmentStartFields(ModelView):
'Stock Search Shipment Start'
__name__ = 'stock.search.shipment.start.field'
search = fields.Many2One('stock.search.shipment.start', 'Search')
name = fields.Char('Code', required=True,
help='The code of the stock shipment you are looking for.')
@ -40,13 +50,13 @@ class StockSearchShipment(Wizard):
('res_model', '=', context['active_model']),
('domain', '=', None),
], limit=1)
shipments = Shipment.search([
('code', '=', self.start.name),
], limit=1)
codes = [s.name for s in self.start.shipments]
shipments = [s.id for s in Shipment.search([
('code', 'in', codes),
])]
if shipments:
shipment, = shipments
action['pyson_domain'] = PYSONEncoder().encode([
('id', '=', shipment.id),
('id', 'in', shipments),
])
if context['active_model'] != 'stock.shipment.out':
action['res_model'] = context['active_model']
@ -62,4 +72,5 @@ class StockSearchShipment(Wizard):
])]
del action['act_window_domains']
action['domains'] = []
self.start.shipments = None
return action, {}

View File

@ -4,10 +4,17 @@ 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="stock_search_shipment_start_field_form_view">
<field name="model">stock.search.shipment.start.field</field>
<field name="type">tree</field>
<field name="name">stock_search_shipment_start_field_tree</field>
</record>
<record model="ir.ui.view" id="stock_search_shipment_start_form_view">
<field name="model">stock.search.shipment.start</field>
<field name="type">form</field>
<field name="name">stock_search_shipment_start</field>
<field name="name">stock_search_shipment_start_form</field>
</record>
<record model="ir.action.wizard" id="stock_search_shipment_wizard">

View File

@ -2,7 +2,7 @@
<!-- This file is part of the stock_search_shipment module for Tryton.
The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<form string="Stock Search Shipment">
<label name="name"/>
<tree string="Stock Search Shipment" editable="bottom">
<field name="name"/>
</form>
<field name="search"/>
</tree>

View File

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!-- This file is part of the stock_search_shipment module for Tryton.
The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<form string="Stock Search Shipment">
<field name="shipments"
view_ids="stock_search_shipment.stock_search_shipment_start_field_form_view"/>
</form>