Add Shipment in return.

This commit refs #4650
This commit is contained in:
Sergio Morillo 2018-05-21 15:44:28 +02:00
parent fcc644078f
commit 77e4c290f2
7 changed files with 91 additions and 39 deletions

View File

@ -5,8 +5,8 @@ from .load import (Load, LoadOrder, LoadOrderLine, LoadOrderIncoterm,
LoadSheet, CMR, RoadTransportNote, PrintLoadOrderShipment)
from .configuration import Configuration
from .sale import (Sale, CostType, CostTemplate, CostSale, CostSaleLine)
from .stock import (Move, ShipmentOut, ShipmentInternal, LoadShipmentInternal,
ShipmentOutReturn)
from .stock import (Move, ShipmentOut, ShipmentInternal, LoadShipment,
ShipmentOutReturn, ShipmentInReturn)
from .purchase import Purchase
from .carrier import Carrier
@ -29,6 +29,7 @@ def register():
ShipmentOut,
ShipmentInternal,
ShipmentOutReturn,
ShipmentInReturn,
module='carrier_load', type_='model')
Pool.register(
LoadSheet,
@ -37,5 +38,5 @@ def register():
module='carrier_load', type_='report')
Pool.register(
PrintLoadOrderShipment,
LoadShipmentInternal,
LoadShipment,
module='carrier_load', type_='wizard')

27
load.py
View File

@ -129,6 +129,13 @@ class Load(Workflow, ModelView, ModelSQL, DockMixin):
Purchase = pool.get('purchase.purchase')
cls.purchase_state._field.selection.extend(Purchase.state.selection)
@classmethod
def view_attributes(cls):
if Transaction().context.get('loading_shipment', False):
return [('//group[@id="state_buttons"]', 'states',
{'invisible': True})]
return []
@staticmethod
def default_code_readonly():
Configuration = Pool().get('carrier.configuration')
@ -381,13 +388,13 @@ class LoadOrder(Workflow, ModelView, ModelSQL, IncotermDocumentMixin):
lines = fields.One2Many('carrier.load.order.line', 'order', 'Lines',
states={'readonly': Eval('state') != 'draft'},
depends=['state'])
party = fields.Many2One('party.party', 'Party', select=True,
states={'readonly': (Eval('state') != 'draft') |
(Eval('lines', [0])),
'required': (Eval('state') == 'done') &
(Eval('type') == 'out'),
'invisible': Eval('type') == 'internal'},
depends=['state', 'lines', 'type'])
party = fields.Many2One('party.party', 'Party', select=True, states={
'readonly': (Eval('state') != 'draft') |
(Eval('lines', [0])),
'required': (Eval('state') == 'done') &
(Eval('type') != 'internal'),
'invisible': Eval('type') == 'internal'},
depends=['state', 'lines', 'type'])
incoterms = fields.One2Many('carrier.load.order.incoterm', 'order', 'Incoterms',
states={'readonly': ~Eval('state').in_(['draft', 'waiting']),
'invisible': ~Eval('party')},
@ -416,7 +423,8 @@ class LoadOrder(Workflow, ModelView, ModelSQL, IncotermDocumentMixin):
'get_carrier_amount')
type = fields.Selection([
('out', 'Out'),
('internal', 'Internal')], 'Type', required=True, select=True,
('internal', 'Internal'),
('in_return', 'In return')], 'Type', required=True, select=True,
states={'readonly': Bool(Eval('lines', [])) |
Bool(Eval('shipment', None)) |
(Eval('state') != 'draft')},
@ -586,7 +594,8 @@ class LoadOrder(Workflow, ModelView, ModelSQL, IncotermDocumentMixin):
def _get_shipments(cls):
return ['stock.shipment.out',
'stock.shipment.out.return',
'stock.shipment.internal']
'stock.shipment.internal',
'stock.shipment.in.return']
@fields.depends('load')
def on_change_with_date(self, name=None):

View File

@ -286,6 +286,10 @@ msgctxt "selection:carrier.load.order,type:"
msgid "Internal"
msgstr "Interna"
msgctxt "selection:carrier.load.order,type:"
msgid "In return"
msgstr "Devolución entrada"
msgctxt "field:carrier.load.order.incoterm,create_date:"
msgid "Create Date"
msgstr "Fecha creación"
@ -967,19 +971,30 @@ msgctxt "field:stock.shipment.internal,load:"
msgid "Load"
msgstr "Carga"
msgctxt "field:stock.shipment.in.return,load:"
msgid "Load"
msgstr "Carga"
msgctxt "field:stock.shipment,load:"
msgid "Load"
msgstr "Carga"
msgctxt "model:ir.action,name:wizard_load_shipment_internal"
msgid "Load Shipments"
msgstr "Cargar albaranes"
msgctxt "model:stock.shipment.internal.load,name:"
msgid "Load Shipment internal"
msgstr "Cargar albarán interno"
msgctxt "model:stock.shipment.load,name:"
msgid "Load Shipment"
msgstr "Cargar albarán"
msgctxt "wizard_button:stock.shipment.internal.load,load,end:"
msgctxt "wizard_button:stock.shipment.load,load,end:"
msgid "Cancel"
msgstr "Cancelar"
msgctxt "wizard_button:stock.shipment.internal.load,load,associate:"
msgctxt "wizard_button:stock.shipment.load,load,associate:"
msgid "Associate"
msgstr "Asociar"
msgctxt "model:ir.action,name:wizard_load_shipment_in_return"
msgid "Load Shipments"
msgstr "Cargar albaranes"

View File

@ -6,7 +6,7 @@ from trytond.wizard import Wizard, StateTransition, StateView, Button
from trytond.transaction import Transaction
__all__ = ['Move', 'ShipmentOut', 'ShipmentInternal',
'LoadShipmentInternal', 'ShipmentOutReturn']
'LoadShipment', 'ShipmentOutReturn', 'ShipmentInReturn']
class Move:
@ -74,12 +74,25 @@ class ShipmentInternal(ShipmentLoadMixin):
__name__ = 'stock.shipment.internal'
class LoadShipmentInternal(Wizard):
"""Load Shipment internal"""
__name__ = 'stock.shipment.internal.load'
class ShipmentInReturn(ShipmentLoadMixin):
__metaclass__ = PoolMeta
__name__ = 'stock.shipment.in.return'
class LoadStateView(StateView):
def get_view(self, wizard, state_name):
with Transaction().set_context(loading_shipment=True):
return super(LoadStateView, self).get_view(
wizard, state_name)
class LoadShipment(Wizard):
"""Load Shipment"""
__name__ = 'stock.shipment.load'
start = StateTransition()
load = StateView('carrier.load',
load = LoadStateView('carrier.load',
'carrier_load.load_view_form',
[Button('Cancel', 'end', 'tryton-cancel'),
Button('Associate', 'associate', 'tryton-ok')])
@ -87,7 +100,7 @@ class LoadShipmentInternal(Wizard):
def transition_start(self):
pool = Pool()
Shipment = pool.get('stock.shipment.internal')
Shipment = pool.get(Transaction().context['active_model'])
shipments = Shipment.browse(Transaction().context['active_ids'])
for shipment in shipments:
@ -97,7 +110,7 @@ class LoadShipmentInternal(Wizard):
def default_load(self, fields):
pool = Pool()
Shipment = pool.get('stock.shipment.internal')
Shipment = pool.get(Transaction().context['active_model'])
shipments = Shipment.browse(
Transaction().context.get('active_ids'))
@ -110,7 +123,7 @@ class LoadShipmentInternal(Wizard):
def transition_associate(self):
pool = Pool()
LoadOrder = pool.get('carrier.load.order')
Shipment = pool.get('stock.shipment.internal')
Shipment = pool.get(Transaction().context['active_model'])
shipments = Shipment.browse(Transaction().context['active_ids'])
@ -119,9 +132,12 @@ class LoadShipmentInternal(Wizard):
order = LoadOrder(
shipment=shipment,
load=self.load,
type='internal',
to_location=shipment.to_location.id,
type=Shipment.__name__[15:].replace('.', '_'),
state='draft')
if order.type == 'internal':
order.to_location = shipment.to_location.id
elif order.type == 'in_return':
order.party = shipment.supplier.id
orders.append(order)
self.load.orders = orders
self.load.save()

View File

@ -4,28 +4,35 @@
<!-- Shipment out -->
<record model="ir.ui.view" id="shipment_out_view_tree">
<field name="model">stock.shipment.out</field>
<field name="name">shipment_out_view_tree</field>
<field name="name">shipment_view_tree</field>
<field name="inherit" ref="stock.shipment_out_view_tree"/>
</record>
<!-- Shipment out return -->
<record model="ir.ui.view" id="shipment_out_return_view_tree">
<field name="model">stock.shipment.out.return</field>
<field name="name">shipment_out_view_tree</field>
<field name="name">shipment_view_tree</field>
<field name="inherit" ref="stock.shipment_out_return_view_tree"/>
</record>
<!-- Shipment internal -->
<record model="ir.ui.view" id="shipment_internal_view_tree">
<field name="model">stock.shipment.internal</field>
<field name="name">shipment_internal_view_tree</field>
<field name="name">shipment_view_tree</field>
<field name="inherit" ref="stock.shipment_internal_view_tree"/>
</record>
<!-- Shipment in return -->
<record model="ir.ui.view" id="shipment_in_return_view_tree">
<field name="model">stock.shipment.in.return</field>
<field name="name">shipment_view_tree</field>
<field name="inherit" ref="stock.shipment_in_return_view_tree"/>
</record>
<!-- Wizard Load Shipment internal -->
<record model="ir.action.wizard" id="wizard_load_shipment_internal">
<field name="name">Load Shipments</field>
<field name="wiz_name">stock.shipment.internal.load</field>
<field name="wiz_name">stock.shipment.load</field>
<field name="model">stock.shipment.internal</field>
</record>
<record model="ir.action.keyword" id="act_load_shipment_internal_keyword1">
@ -33,5 +40,17 @@
<field name="model">stock.shipment.internal,-1</field>
<field name="action" ref="wizard_load_shipment_internal"/>
</record>
<!-- Wizard Load Shipment in return -->
<record model="ir.action.wizard" id="wizard_load_shipment_in_return">
<field name="name">Load Shipments</field>
<field name="wiz_name">stock.shipment.load</field>
<field name="model">stock.shipment.in.return</field>
</record>
<record model="ir.action.keyword" id="act_load_shipment_in_return_keyword1">
<field name="keyword">form_action</field>
<field name="model">stock.shipment.in.return,-1</field>
<field name="action" ref="wizard_load_shipment_in_return"/>
</record>
</data>
</tryton>

View File

@ -1,8 +0,0 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/tree/field[@name='reference']" position="after">
<field name="load"/>
</xpath>
</data>