Add issue5587 patches.
This commit is contained in:
parent
c7b6a2bff6
commit
bd59495395
|
@ -1,6 +1,18 @@
|
|||
diff -r da3bbc1a1ccc trytond/trytond/modules/stock/__init__.py
|
||||
--- a/trytond/trytond/modules/stock/__init__.py Wed Jun 22 11:28:23 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/__init__.py Wed Jun 22 16:09:23 2016 +0200
|
||||
exporting patch:
|
||||
# HG changeset patch
|
||||
# User Cédric Krier <ced@b2ck.com>
|
||||
# Date 1466498190 -7200
|
||||
# Tue Jun 21 10:36:30 2016 +0200
|
||||
# Node ID 48fdd650ed0c3a42495711a1a16eaba2aef30bae
|
||||
# Parent 6de0e55a67d0dc6211d7a7d74d561a5cc8686640
|
||||
Add lead time and transit location for internal shipments between warehouses
|
||||
|
||||
issue5587
|
||||
review25331002
|
||||
|
||||
diff -r 6de0e55a67d0 -r 48fdd650ed0c __init__.py
|
||||
--- a/trytond/trytond/modules/stock/__init__.py Wed Jun 15 10:45:54 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/__init__.py Tue Jun 21 10:36:30 2016 +0200
|
||||
@@ -16,6 +16,7 @@
|
||||
Location,
|
||||
Party,
|
||||
|
@ -9,9 +21,9 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/__init__.py
|
|||
Move,
|
||||
ShipmentIn,
|
||||
ShipmentInReturn,
|
||||
diff -r da3bbc1a1ccc trytond/trytond/modules/stock/configuration.py
|
||||
--- a/trytond/trytond/modules/stock/configuration.py Wed Jun 22 11:28:23 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/configuration.py Wed Jun 22 16:09:23 2016 +0200
|
||||
diff -r 6de0e55a67d0 -r 48fdd650ed0c configuration.py
|
||||
--- a/trytond/trytond/modules/stock/configuration.py Wed Jun 15 10:45:54 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/configuration.py Tue Jun 21 10:36:30 2016 +0200
|
||||
@@ -39,6 +39,10 @@
|
||||
[Eval('context', {}).get('company', -1), None]),
|
||||
('code', '=', 'stock.shipment.internal'),
|
||||
|
@ -23,128 +35,54 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/configuration.py
|
|||
inventory_sequence = fields.Property(fields.Many2One(
|
||||
'ir.sequence', 'Inventory Sequence', domain=[
|
||||
('company', 'in',
|
||||
diff -r da3bbc1a1ccc trytond/trytond/modules/stock/location.py
|
||||
--- a/trytond/trytond/modules/stock/location.py Wed Jun 22 11:28:23 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/location.py Wed Jun 22 16:09:23 2016 +0200
|
||||
@@ -2,16 +2,18 @@
|
||||
#this repository contains the full copyright notices and license terms.
|
||||
diff -r 6de0e55a67d0 -r 48fdd650ed0c doc/index.rst
|
||||
--- a/trytond/trytond/modules/stock/doc/index.rst Wed Jun 15 10:45:54 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/doc/index.rst Tue Jun 21 10:36:30 2016 +0200
|
||||
@@ -50,6 +50,12 @@
|
||||
Locations are organised in tree structures, allowing to define
|
||||
fine grained structures.
|
||||
|
||||
+Location Lead Time
|
||||
+------------------
|
||||
+
|
||||
+It allows to define the time needed for an *Internal Shipment* between two
|
||||
+warehouses.
|
||||
+
|
||||
|
||||
Move
|
||||
****
|
||||
diff -r 4c390625785a location.py
|
||||
--- a/trytond/trytond/modules/stock/location.py Tue Jun 14 16:17:48 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/location.py Thu Aug 04 01:14:15 2016 +0200
|
||||
@@ -2,7 +2,11 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
import datetime
|
||||
from decimal import Decimal
|
||||
-from trytond.model import ModelView, ModelSQL, fields
|
||||
+
|
||||
+from sql import Null
|
||||
+from sql.conditionals import Case
|
||||
+
|
||||
+from trytond.model import ModelView, ModelSQL, MatchMixin, fields
|
||||
from trytond.wizard import Wizard, StateView, Button, StateAction
|
||||
from trytond import backend
|
||||
-from trytond.pyson import Not, Bool, Eval, Equal, PYSONEncoder, Date
|
||||
+from trytond.pyson import Not, Bool, Eval, In, Equal, PYSONEncoder, Date
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Eval, PYSONEncoder, Date, If
|
||||
@@ -11,7 +15,7 @@
|
||||
from trytond.tools import grouped_slice
|
||||
|
||||
__all__ = ['Location', 'Party', 'ProductsByLocationsStart',
|
||||
- 'ProductsByLocations']
|
||||
+ 'ProductsByLocations', 'LocationLeadTime']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
STATES = {
|
||||
@@ -48,6 +50,12 @@
|
||||
left = fields.Integer('Left', required=True, select=True)
|
||||
right = fields.Integer('Right', required=True, select=True)
|
||||
childs = fields.One2Many("stock.location", "parent", "Children")
|
||||
+ warehouse = fields.Function(fields.Many2One('stock.location', 'Warehouse',
|
||||
+ states={
|
||||
+ 'invisible': Not(In(Eval('type'), ['storage', 'view']))
|
||||
+ },
|
||||
+ depends=['type']),
|
||||
+ 'get_warehouse', searcher='search_warehouse')
|
||||
input_location = fields.Many2One(
|
||||
"stock.location", "Input", states={
|
||||
'invisible': Not(Equal(Eval('type'), 'warehouse')),
|
||||
@@ -96,6 +104,10 @@
|
||||
def __setup__(cls):
|
||||
super(Location, cls).__setup__()
|
||||
cls._order.insert(0, ('name', 'ASC'))
|
||||
+ cls._sql_constraints += [
|
||||
+ ('storage_location_unique', 'UNIQUE(storage_location)',
|
||||
+ 'The Storage location must be unique.'),
|
||||
+ ]
|
||||
cls._error_messages.update({
|
||||
'invalid_type_for_moves': ('Location "%s" with existing moves '
|
||||
'cannot be changed to a type that does not support moves.'
|
||||
@@ -337,6 +349,66 @@
|
||||
res.append(new_location)
|
||||
return res
|
||||
|
||||
+ @fields.depends('type', 'parent')
|
||||
+ def on_change_with_warehouse(self, name=None):
|
||||
+ if (not self.id or self.type not in ('storage', 'view') or
|
||||
+ not self.parent):
|
||||
+ return None
|
||||
+ return self.parent.warehouse and self.parent.warehouse.id or None
|
||||
+
|
||||
+ @classmethod
|
||||
+ def get_warehouse(cls, instances, name):
|
||||
+ warehouse_per_location = {}
|
||||
+ for warehouse in cls.search([('type', '=', 'warehouse')]):
|
||||
+ warehouse_per_location[warehouse.storage_location.id] = (
|
||||
+ warehouse.id)
|
||||
+ warehouse_per_location[warehouse.input_location.id] = (
|
||||
+ warehouse.id)
|
||||
+ warehouse_per_location[warehouse.output_location.id] = (
|
||||
+ warehouse.id)
|
||||
+ res = {}
|
||||
+ for location in instances:
|
||||
+ res[location.id] = None
|
||||
+ if location.type not in ('storage', 'view'):
|
||||
+ continue
|
||||
+ child_location_ids = []
|
||||
+ current_location = location
|
||||
+ while current_location:
|
||||
+ child_location_ids.append(current_location.id)
|
||||
+ if location.type not in ('storage', 'view'):
|
||||
+ warehouse_per_location.update(
|
||||
+ {}.fromkeys(child_location_ids, None))
|
||||
+ break
|
||||
+ if current_location.id in warehouse_per_location:
|
||||
+ warehouse_id = warehouse_per_location[current_location.id]
|
||||
+ res[location.id] = warehouse_id
|
||||
+ warehouse_per_location.update(
|
||||
+ {}.fromkeys(child_location_ids, warehouse_id))
|
||||
+ break
|
||||
+ current_location = current_location.parent
|
||||
+ return res
|
||||
+
|
||||
+ @classmethod
|
||||
+ def search_warehouse(cls, name, clause):
|
||||
+ warehouse_child_locations = cls.search([
|
||||
+ ('parent.type', '=', 'warehouse'),
|
||||
+ ('type', '=', 'storage'),
|
||||
+ ('parent', clause[1], clause[2]),
|
||||
+ ])
|
||||
+ found_warehouse_ids = []
|
||||
+ storage_location_ids = []
|
||||
+ for location in warehouse_child_locations:
|
||||
+ storage_location_ids.append(location.id)
|
||||
+ found_warehouse_ids.append(location.parent.id)
|
||||
+
|
||||
+ warehouse_location_ids = []
|
||||
+ for location in cls.search([
|
||||
+ ('parent', 'child_of', storage_location_ids),
|
||||
+ ]):
|
||||
+ if location.warehouse.id in found_warehouse_ids:
|
||||
+ warehouse_location_ids.append(location.id)
|
||||
+ return [('id', 'in', warehouse_location_ids)]
|
||||
+
|
||||
|
||||
class Party:
|
||||
__name__ = 'party.party'
|
||||
@@ -400,3 +472,37 @@
|
||||
'readonly': ~Eval('active'),
|
||||
@@ -456,3 +460,38 @@
|
||||
action['name'] += ' - (%s) @ %s' % (
|
||||
','.join(l.name for l in locations), date)
|
||||
return action, {}
|
||||
+
|
||||
+
|
||||
+
|
||||
+class LocationLeadTime(ModelSQL, ModelView, MatchMixin):
|
||||
+ 'Location Lead Time'
|
||||
+ __name__ = 'stock.location.lead_time'
|
||||
|
@ -160,7 +98,7 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/location.py
|
|||
+ domain=[
|
||||
+ ('type', '=', 'warehouse'),
|
||||
+ ])
|
||||
+ lead_time = fields.Float('Lead Time', digits=(16, 2))
|
||||
+ lead_time = fields.TimeDelta('Lead Time')
|
||||
+
|
||||
+ @classmethod
|
||||
+ def __setup__(cls):
|
||||
|
@ -177,13 +115,13 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/location.py
|
|||
+ for record in cls.search([]):
|
||||
+ if record.match(pattern):
|
||||
+ return record.lead_time
|
||||
diff -r da3bbc1a1ccc trytond/trytond/modules/stock/location.xml
|
||||
--- a/trytond/trytond/modules/stock/location.xml Wed Jun 22 11:28:23 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/location.xml Wed Jun 22 16:09:23 2016 +0200
|
||||
diff -r 6de0e55a67d0 -r 48fdd650ed0c location.xml
|
||||
--- a/trytond/trytond/modules/stock/location.xml Wed Jun 15 10:45:54 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/location.xml Tue Jun 21 10:36:30 2016 +0200
|
||||
@@ -121,6 +121,56 @@
|
||||
<field name="name">products_by_locations_start_form</field>
|
||||
</record>
|
||||
|
||||
|
||||
+ <record model="ir.ui.view" id="location_lead_time_view_list">
|
||||
+ <field name="model">stock.location.lead_time</field>
|
||||
+ <field name="type">tree</field>
|
||||
|
@ -261,12 +199,12 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/location.xml
|
|||
+ </record>
|
||||
</data>
|
||||
</tryton>
|
||||
diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.py
|
||||
--- a/trytond/trytond/modules/stock/shipment.py Wed Jun 22 11:28:23 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/shipment.py Wed Jun 22 16:09:23 2016 +0200
|
||||
@@ -3,7 +3,9 @@
|
||||
import operator
|
||||
diff -r 6de0e55a67d0 -r 48fdd650ed0c shipment.py
|
||||
--- a/trytond/trytond/modules/stock/shipment.py Wed Jun 15 10:45:54 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/shipment.py Tue Jun 21 10:36:30 2016 +0200
|
||||
@@ -4,7 +4,9 @@
|
||||
import itertools
|
||||
import functools
|
||||
import datetime
|
||||
-from sql import Table
|
||||
+from collections import defaultdict
|
||||
|
@ -275,9 +213,18 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.py
|
|||
from sql.functions import Overlay, Position
|
||||
from sql.aggregate import Max
|
||||
from sql.operators import Concat
|
||||
@@ -1774,6 +1776,17 @@
|
||||
@@ -13,7 +15,7 @@
|
||||
from trytond.modules.company import CompanyReport
|
||||
from trytond.wizard import Wizard, StateTransition, StateView, Button
|
||||
from trytond import backend
|
||||
-from trytond.pyson import Eval, If, Id
|
||||
+from trytond.pyson import Eval, If, Id, Bool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.tools import reduce_ids, grouped_slice
|
||||
@@ -1819,6 +1821,17 @@
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, depends=['state'])
|
||||
+ effective_start_date = fields.Date('Effective Start Date',
|
||||
+ states={
|
||||
|
@ -292,10 +239,10 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.py
|
|||
+ depends=['state'])
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
@@ -1803,30 +1816,86 @@
|
||||
'readonly': Eval('state') != 'draft',
|
||||
@@ -1846,32 +1859,88 @@
|
||||
}, domain=[
|
||||
('type', 'in', ['storage', 'lost_found']),
|
||||
('type', 'in', ['view', 'storage', 'lost_found']),
|
||||
], depends=['state'])
|
||||
+ transit_location = fields.Function(fields.Many2One('stock.location',
|
||||
+ 'Transit Location'), 'on_change_with_transit_location')
|
||||
|
@ -380,15 +327,23 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.py
|
|||
+ 'state']),
|
||||
+ 'get_incoming_moves', setter='set_moves')
|
||||
state = fields.Selection([
|
||||
('draft', 'Draft'),
|
||||
('cancel', 'Canceled'),
|
||||
('assigned', 'Assigned'),
|
||||
('waiting', 'Waiting'),
|
||||
+ ('shipped', 'Shipped'),
|
||||
('done', 'Done'),
|
||||
], 'State', readonly=True)
|
||||
- ('draft', 'Draft'),
|
||||
- ('cancel', 'Canceled'),
|
||||
- ('assigned', 'Assigned'),
|
||||
- ('waiting', 'Waiting'),
|
||||
- ('done', 'Done'),
|
||||
- ], 'State', readonly=True)
|
||||
+ ('draft', 'Draft'),
|
||||
+ ('cancel', 'Canceled'),
|
||||
+ ('waiting', 'Waiting'),
|
||||
+ ('assigned', 'Assigned'),
|
||||
+ ('shipped', 'Shipped'),
|
||||
+ ('done', 'Done'),
|
||||
+ ], 'State', readonly=True)
|
||||
|
||||
@@ -1842,7 +1911,9 @@
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
@@ -1885,7 +1954,9 @@
|
||||
('draft', 'waiting'),
|
||||
('waiting', 'waiting'),
|
||||
('waiting', 'assigned'),
|
||||
|
@ -398,16 +353,17 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.py
|
|||
('waiting', 'draft'),
|
||||
('assigned', 'waiting'),
|
||||
('draft', 'cancel'),
|
||||
@@ -1852,7 +1923,7 @@
|
||||
@@ -1895,7 +1966,8 @@
|
||||
))
|
||||
cls._buttons.update({
|
||||
'cancel': {
|
||||
- 'invisible': Eval('state').in_(['cancel', 'done']),
|
||||
+ 'invisible': Eval('state').in_(['cancel', 'shipped', 'done']),
|
||||
+ 'invisible': Eval('state').in_(
|
||||
+ ['cancel', 'shipped', 'done']),
|
||||
},
|
||||
'draft': {
|
||||
'invisible': ~Eval('state').in_(['cancel', 'waiting']),
|
||||
@@ -1869,8 +1940,15 @@
|
||||
@@ -1912,8 +1984,15 @@
|
||||
'tryton-clear',
|
||||
'tryton-go-next')),
|
||||
},
|
||||
|
@ -424,11 +380,12 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.py
|
|||
},
|
||||
'assign_wizard': {
|
||||
'invisible': Eval('state') != 'waiting',
|
||||
@@ -1924,6 +2002,13 @@
|
||||
@@ -1971,6 +2050,14 @@
|
||||
where=red_sql))
|
||||
table.not_null_action('company', action='add')
|
||||
|
||||
+ # Migration from 4.0: fill planned_start_date
|
||||
+ cursor = Transaction().connection.cursor()
|
||||
+ cursor.execute(*sql_table.update(
|
||||
+ [sql_table.planned_start_date],
|
||||
+ [sql_table.planned_date],
|
||||
|
@ -436,9 +393,9 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.py
|
|||
+ & (sql_table.planned_date != Null)))
|
||||
+
|
||||
# Add index on create_date
|
||||
table = TableHandler(cursor, cls, module_name)
|
||||
table = TableHandler(cls, module_name)
|
||||
table.index_action('create_date', action='add')
|
||||
@@ -1936,6 +2021,59 @@
|
||||
@@ -1983,6 +2070,59 @@
|
||||
def default_company():
|
||||
return Transaction().context.get('company')
|
||||
|
||||
|
@ -498,7 +455,7 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.py
|
|||
@classmethod
|
||||
def create(cls, vlist):
|
||||
pool = Pool()
|
||||
@@ -1961,12 +2099,73 @@
|
||||
@@ -2009,13 +2149,76 @@
|
||||
super(ShipmentInternal, cls).delete(shipments)
|
||||
|
||||
@classmethod
|
||||
|
@ -531,7 +488,7 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.py
|
|||
+ Move = pool.get('stock.move')
|
||||
+ Uom = pool.get('product.uom')
|
||||
+ to_delete = []
|
||||
+ to_write = []
|
||||
+ to_save = []
|
||||
+ for shipment in shipments:
|
||||
+ product_qty = defaultdict(lambda: 0)
|
||||
+ for move in shipment.outgoing_moves:
|
||||
|
@ -554,42 +511,50 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.py
|
|||
+ move.quantity = Uom.compute_qty(
|
||||
+ move.product.default_uom, quantity, move.uom)
|
||||
+ product_qty[move.product] -= quantity
|
||||
+ to_write.extend(([move], move._save_values))
|
||||
+ if to_write:
|
||||
+ Move.write(*to_write)
|
||||
+ to_save.append(move)
|
||||
+
|
||||
+ if to_save:
|
||||
+ Move.save(to_save)
|
||||
+ if to_delete:
|
||||
+ Move.delete([m.id for m in to_delete])
|
||||
+ Move.delete(to_delete)
|
||||
+
|
||||
+ @classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('draft')
|
||||
def draft(cls, shipments):
|
||||
Move = Pool().get('stock.move')
|
||||
+
|
||||
# First reset state to draft to allow update from and to location
|
||||
Move.draft([m for s in shipments for m in s.moves])
|
||||
Move.draft([m for s in shipments for m in s.moves
|
||||
if m.state != 'staging'])
|
||||
+ Move.delete([m for s in shipments for m in s.moves
|
||||
+ if m.from_location == s.transit_location])
|
||||
for shipment in shipments:
|
||||
Move.write([m for m in shipment.moves
|
||||
if m.state != 'done'], {
|
||||
@@ -1981,25 +2180,65 @@
|
||||
@@ -2029,28 +2232,69 @@
|
||||
@Workflow.transition('waiting')
|
||||
def wait(cls, shipments):
|
||||
Move = Pool().get('stock.move')
|
||||
+
|
||||
Move.draft([m for s in shipments for m in s.moves])
|
||||
+
|
||||
+ direct = []
|
||||
+ transit = []
|
||||
for shipment in shipments:
|
||||
+ for shipment in shipments:
|
||||
+ if not shipment.transit_location:
|
||||
+ direct.append(shipment)
|
||||
+ else:
|
||||
+ transit.append(shipment)
|
||||
+
|
||||
moves = []
|
||||
- for shipment in shipments:
|
||||
+ for shipment in direct:
|
||||
for move in shipment.moves:
|
||||
if move.state != 'done':
|
||||
move.planned_date = shipment.planned_date
|
||||
move.save()
|
||||
moves.append(move)
|
||||
Move.save(moves)
|
||||
|
||||
+ to_write = []
|
||||
+ for shipment in transit:
|
||||
|
@ -639,7 +604,7 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.py
|
|||
cls.write([s for s in shipments if not s.effective_date], {
|
||||
'effective_date': Date.today(),
|
||||
})
|
||||
@@ -2020,7 +2259,7 @@
|
||||
@@ -2071,7 +2315,7 @@
|
||||
@ModelView.button
|
||||
def assign_try(cls, shipments):
|
||||
Move = Pool().get('stock.move')
|
||||
|
@ -648,7 +613,7 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.py
|
|||
if m.from_location.type != 'lost_found']
|
||||
if not to_assign or Move.assign_try(to_assign):
|
||||
cls.assign(shipments)
|
||||
@@ -2032,7 +2271,7 @@
|
||||
@@ -2083,7 +2327,7 @@
|
||||
@ModelView.button
|
||||
def assign_force(cls, shipments):
|
||||
Move = Pool().get('stock.move')
|
||||
|
@ -657,7 +622,7 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.py
|
|||
cls.assign(shipments)
|
||||
|
||||
|
||||
@@ -2054,7 +2293,7 @@
|
||||
@@ -2106,7 +2350,7 @@
|
||||
if not shipment_id:
|
||||
return []
|
||||
shipment = ShipmentInternal(shipment_id)
|
||||
|
@ -666,26 +631,101 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.py
|
|||
|
||||
|
||||
class AssignShipmentInternal(Wizard):
|
||||
diff -r da3bbc1a1ccc trytond/trytond/modules/stock/shipment.xml
|
||||
--- a/trytond/trytond/modules/stock/shipment.xml Wed Jun 22 11:28:23 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/shipment.xml Wed Jun 22 16:09:23 2016 +0200
|
||||
@@ -251,6 +251,13 @@
|
||||
diff -r 6de0e55a67d0 -r 48fdd650ed0c shipment.xml
|
||||
--- a/trytond/trytond/modules/stock/shipment.xml Wed Jun 15 10:45:54 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/shipment.xml Tue Jun 21 10:36:30 2016 +0200
|
||||
@@ -263,6 +263,13 @@
|
||||
<field name="act_window" ref="act_shipment_internal_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain"
|
||||
+ id="act_shipment_internal_form_domain_shipped">
|
||||
+ <field name="name">Shipped</field>
|
||||
+ <field name="sequence" eval="40"/>
|
||||
+ <field name="domain">[('state', '=', 'shipped')]</field>
|
||||
+ <field name="domain" eval="[('state', '=', 'shipped')]" pyson="1"/>
|
||||
+ <field name="act_window" ref="act_shipment_internal_form"/>
|
||||
+ </record>
|
||||
+ <record model="ir.action.act_window.domain"
|
||||
id="act_shipment_internal_form_domain_all">
|
||||
<field name="name">All</field>
|
||||
<field name="sequence" eval="9999"/>
|
||||
diff -r da3bbc1a1ccc trytond/trytond/modules/stock/view/configuration_form.xml
|
||||
--- a/trytond/trytond/modules/stock/view/configuration_form.xml Wed Jun 22 11:28:23 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/view/configuration_form.xml Wed Jun 22 16:09:23 2016 +0200
|
||||
diff -r 6de0e55a67d0 -r 48fdd650ed0c tests/scenario_stock_shipment_internal.rst
|
||||
--- a/trytond/trytond/modules/stock/tests/scenario_stock_shipment_internal.rst Wed Jun 15 10:45:54 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/tests/scenario_stock_shipment_internal.rst Tue Jun 21 10:36:30 2016 +0200
|
||||
@@ -12,6 +12,7 @@
|
||||
... get_company
|
||||
>>> today = datetime.date.today()
|
||||
>>> yesterday = today - relativedelta(days=1)
|
||||
+ >>> tomorrow = today + relativedelta(days=1)
|
||||
|
||||
Create database::
|
||||
|
||||
@@ -103,7 +104,7 @@
|
||||
>>> move = lost_found_shipment.moves.new()
|
||||
>>> move.product = product
|
||||
>>> move.oum = unit
|
||||
- >>> move.quantity = 1
|
||||
+ >>> move.quantity = 2
|
||||
>>> move.from_location = lost_found_loc
|
||||
>>> move.to_location = internal_loc
|
||||
>>> move.currency = company.currency
|
||||
@@ -123,3 +124,54 @@
|
||||
>>> shipment.click('done')
|
||||
>>> shipment.state
|
||||
u'done'
|
||||
+
|
||||
+Add lead time inside the warehouse::
|
||||
+
|
||||
+ >>> config.user = 1
|
||||
+ >>> LeadTime = Model.get('stock.location.lead_time')
|
||||
+ >>> lead_time = LeadTime()
|
||||
+ >>> lead_time.from_warehouse = storage_loc.warehouse
|
||||
+ >>> lead_time.to_warehouse = storage_loc.warehouse
|
||||
+ >>> lead_time.lead_time = datetime.timedelta(1)
|
||||
+ >>> lead_time.save()
|
||||
+
|
||||
+Create Internal Shipment with lead time::
|
||||
+
|
||||
+ >>> config.user = stock_user.id
|
||||
+ >>> shipment = Shipment()
|
||||
+ >>> shipment.planned_date = tomorrow
|
||||
+ >>> shipment.from_location = internal_loc
|
||||
+ >>> shipment.to_location = storage_loc
|
||||
+ >>> shipment.planned_start_date == today
|
||||
+ True
|
||||
+ >>> move = shipment.moves.new()
|
||||
+ >>> move.product = product
|
||||
+ >>> move.quantity = 1
|
||||
+ >>> move.from_location = internal_loc
|
||||
+ >>> move.to_location = storage_loc
|
||||
+ >>> shipment.click('wait')
|
||||
+ >>> len(shipment.moves)
|
||||
+ 2
|
||||
+ >>> outgoing_move, = shipment.outgoing_moves
|
||||
+ >>> outgoing_move.quantity
|
||||
+ 1.0
|
||||
+ >>> outgoing_move.from_location == internal_loc
|
||||
+ True
|
||||
+ >>> outgoing_move.to_location == shipment.transit_location
|
||||
+ True
|
||||
+ >>> incoming_move, = shipment.incoming_moves
|
||||
+ >>> incoming_move.quantity
|
||||
+ 1.0
|
||||
+ >>> incoming_move.from_location == shipment.transit_location
|
||||
+ True
|
||||
+ >>> incoming_move.to_location == storage_loc
|
||||
+ True
|
||||
+
|
||||
+ >>> shipment.click('assign_try')
|
||||
+ True
|
||||
+ >>> shipment.click('ship')
|
||||
+ >>> shipment.outgoing_moves[0].state
|
||||
+ u'done'
|
||||
+ >>> shipment.click('done')
|
||||
+ >>> shipment.incoming_moves[0].state
|
||||
+ u'done'
|
||||
diff -r 6de0e55a67d0 -r 48fdd650ed0c view/configuration_form.xml
|
||||
--- a/trytond/trytond/modules/stock/view/configuration_form.xml Wed Jun 15 10:45:54 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/view/configuration_form.xml Tue Jun 21 10:36:30 2016 +0200
|
||||
@@ -13,6 +13,8 @@
|
||||
<field name="shipment_out_return_sequence"/>
|
||||
<label name="shipment_internal_sequence"/>
|
||||
|
@ -695,21 +735,9 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/view/configuration_form.xml
|
|||
<separator id="inventory" colspan="4" string="Inventory"/>
|
||||
<label name="inventory_sequence"/>
|
||||
<field name="inventory_sequence"/>
|
||||
diff -r da3bbc1a1ccc trytond/trytond/modules/stock/view/location_form.xml
|
||||
--- a/trytond/trytond/modules/stock/view/location_form.xml Wed Jun 22 11:28:23 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/view/location_form.xml Wed Jun 22 16:09:23 2016 +0200
|
||||
@@ -12,6 +12,8 @@
|
||||
<field name="active"/>
|
||||
<label name="type"/>
|
||||
<field name="type"/>
|
||||
+ <label name="warehouse"/>
|
||||
+ <field name="warehouse"/>
|
||||
<newline/>
|
||||
<label name="address"/>
|
||||
<field name="address"/>
|
||||
diff -r da3bbc1a1ccc trytond/trytond/modules/stock/view/location_lead_time_form.xml
|
||||
diff -r 6de0e55a67d0 -r 48fdd650ed0c view/location_lead_time_form.xml
|
||||
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
||||
+++ b/trytond/trytond/modules/stock/view/location_lead_time_form.xml Wed Jun 22 16:09:23 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/view/location_lead_time_form.xml Tue Jun 21 10:36:30 2016 +0200
|
||||
@@ -0,0 +1,13 @@
|
||||
+<?xml version="1.0"?>
|
||||
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
|
@ -724,9 +752,9 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/view/location_lead_time_form.
|
|||
+ <label name="lead_time"/>
|
||||
+ <field name="lead_time"/>
|
||||
+</form>
|
||||
diff -r da3bbc1a1ccc trytond/trytond/modules/stock/view/location_lead_time_list.xml
|
||||
diff -r 6de0e55a67d0 -r 48fdd650ed0c view/location_lead_time_list.xml
|
||||
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
||||
+++ b/trytond/trytond/modules/stock/view/location_lead_time_list.xml Wed Jun 22 16:09:23 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/view/location_lead_time_list.xml Tue Jun 21 10:36:30 2016 +0200
|
||||
@@ -0,0 +1,8 @@
|
||||
+<?xml version="1.0"?>
|
||||
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
|
@ -736,30 +764,9 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/view/location_lead_time_list.
|
|||
+ <field name="warehouse_to"/>
|
||||
+ <field name="lead_time"/>
|
||||
+</tree>
|
||||
diff -r da3bbc1a1ccc trytond/trytond/modules/stock/view/location_list.xml
|
||||
--- a/trytond/trytond/modules/stock/view/location_list.xml Wed Jun 22 11:28:23 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/view/location_list.xml Wed Jun 22 16:09:23 2016 +0200
|
||||
@@ -5,5 +5,6 @@
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="type"/>
|
||||
+ <field name="warehouse"/>
|
||||
<field name="active" tree_invisible="1"/>
|
||||
</tree>
|
||||
diff -r da3bbc1a1ccc trytond/trytond/modules/stock/view/location_tree.xml
|
||||
--- a/trytond/trytond/modules/stock/view/location_tree.xml Wed Jun 22 11:28:23 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/view/location_tree.xml Wed Jun 22 16:09:23 2016 +0200
|
||||
@@ -5,6 +5,7 @@
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="type"/>
|
||||
+ <field name="warehouse"/>
|
||||
<field name="active" tree_invisible="1"/>
|
||||
<field name="parent" tree_invisible="1"/>
|
||||
<field name="childs" tree_invisible="1"/>
|
||||
diff -r da3bbc1a1ccc trytond/trytond/modules/stock/view/shipment_internal_form.xml
|
||||
--- a/trytond/trytond/modules/stock/view/shipment_internal_form.xml Wed Jun 22 11:28:23 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/view/shipment_internal_form.xml Wed Jun 22 16:09:23 2016 +0200
|
||||
diff -r 6de0e55a67d0 -r 48fdd650ed0c view/shipment_internal_form.xml
|
||||
--- a/trytond/trytond/modules/stock/view/shipment_internal_form.xml Wed Jun 15 10:45:54 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/view/shipment_internal_form.xml Tue Jun 21 10:36:30 2016 +0200
|
||||
@@ -12,18 +12,33 @@
|
||||
<field name="to_location"/>
|
||||
<label name="planned_date"/>
|
||||
|
@ -796,12 +803,12 @@ diff -r da3bbc1a1ccc trytond/trytond/modules/stock/view/shipment_internal_form.x
|
|||
<button string="Done" name="done" icon="tryton-ok"/>
|
||||
</group>
|
||||
</form>
|
||||
diff -r da3bbc1a1ccc trytond/trytond/modules/stock/view/shipment_internal_tree.xml
|
||||
--- a/trytond/trytond/modules/stock/view/shipment_internal_tree.xml Wed Jun 22 11:28:23 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/view/shipment_internal_tree.xml Wed Jun 22 16:09:23 2016 +0200
|
||||
diff -r 6de0e55a67d0 -r 48fdd650ed0c view/shipment_internal_tree.xml
|
||||
--- a/trytond/trytond/modules/stock/view/shipment_internal_tree.xml Wed Jun 15 10:45:54 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock/view/shipment_internal_tree.xml Tue Jun 21 10:36:30 2016 +0200
|
||||
@@ -4,6 +4,7 @@
|
||||
<tree string="Internal Shipments">
|
||||
<field name="code"/>
|
||||
<field name="number"/>
|
||||
<field name="reference"/>
|
||||
+ <field name="planned_start_date"/>
|
||||
<field name="planned_date"/>
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
diff -r 9a0b5b830df9 trytond/trytond/modules/stock_supply/__init__.py
|
||||
--- a/trytond/trytond/modules/stock_supply/__init__.py Wed Jun 22 16:17:37 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock_supply/__init__.py Wed Jun 22 17:05:42 2016 +0200
|
||||
@@ -21,6 +21,7 @@
|
||||
exporting patch:
|
||||
# HG changeset patch
|
||||
# User Cédric Krier <ced@b2ck.com>
|
||||
# Date 1466498284 -7200
|
||||
# Tue Jun 21 10:38:04 2016 +0200
|
||||
# Node ID 2debb3c826595328cfe844ebcf6c19339a548831
|
||||
# Parent 2755f1104ac029ea8f01fee42fa3ffa3177e99c8
|
||||
Manage lead time when generating internal shipments
|
||||
|
||||
issue5587
|
||||
review25331003
|
||||
|
||||
diff -r 2755f1104ac0 -r 2debb3c82659 __init__.py
|
||||
--- a/trytond/trytond/modules/stock_supply/__init__.py Tue Jun 21 10:11:57 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock_supply/__init__.py Tue Jun 21 10:38:04 2016 +0200
|
||||
@@ -18,6 +18,7 @@
|
||||
ShipmentInternal,
|
||||
CreateShipmentInternalStart,
|
||||
Location,
|
||||
|
@ -9,9 +21,9 @@ diff -r 9a0b5b830df9 trytond/trytond/modules/stock_supply/__init__.py
|
|||
module='stock_supply', type_='model')
|
||||
Pool.register(
|
||||
CreatePurchaseRequest,
|
||||
diff -r 9a0b5b830df9 trytond/trytond/modules/stock_supply/location.py
|
||||
--- a/trytond/trytond/modules/stock_supply/location.py Wed Jun 22 16:17:37 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock_supply/location.py Wed Jun 22 17:05:42 2016 +0200
|
||||
diff -r 2755f1104ac0 -r 2debb3c82659 location.py
|
||||
--- a/trytond/trytond/modules/stock_supply/location.py Tue Jun 21 10:11:57 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock_supply/location.py Tue Jun 21 10:38:04 2016 +0200
|
||||
@@ -1,11 +1,13 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
@ -42,21 +54,21 @@ diff -r 9a0b5b830df9 trytond/trytond/modules/stock_supply/location.py
|
|||
+ 'Return the biggest lead time'
|
||||
+ lead_times = cls.search([])
|
||||
+ if lead_times:
|
||||
+ return datetime.timedelta(max(r.lead_time for r in lead_times))
|
||||
+ return max(r.lead_time for r in lead_times)
|
||||
+ else:
|
||||
+ return datetime.timedelta(0)
|
||||
diff -r 9a0b5b830df9 trytond/trytond/modules/stock_supply/shipment.py
|
||||
--- a/trytond/trytond/modules/stock_supply/shipment.py Wed Jun 22 16:17:37 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock_supply/shipment.py Wed Jun 22 17:05:42 2016 +0200
|
||||
diff -r 2755f1104ac0 -r 2debb3c82659 shipment.py
|
||||
--- a/trytond/trytond/modules/stock_supply/shipment.py Tue Jun 21 10:11:57 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock_supply/shipment.py Tue Jun 21 10:38:04 2016 +0200
|
||||
@@ -1,5 +1,7 @@
|
||||
#This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
#this repository contains the full copyright notices and license terms.
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
+import datetime
|
||||
+
|
||||
from sql import Table
|
||||
from sql.functions import Overlay, Position
|
||||
|
||||
@@ -51,8 +53,11 @@
|
||||
@@ -50,8 +52,11 @@
|
||||
Date = pool.get('ir.date')
|
||||
User = pool.get('res.user')
|
||||
Move = pool.get('stock.move')
|
||||
|
@ -68,7 +80,7 @@ diff -r 9a0b5b830df9 trytond/trytond/modules/stock_supply/shipment.py
|
|||
# fetch quantities on order points
|
||||
order_points = OrderPoint.search([
|
||||
('type', '=', 'internal'),
|
||||
@@ -80,60 +85,68 @@
|
||||
@@ -79,61 +84,68 @@
|
||||
else:
|
||||
product_ids = id2product.keys()
|
||||
product_ids.sort()
|
||||
|
@ -116,13 +128,13 @@ diff -r 9a0b5b830df9 trytond/trytond/modules/stock_supply/shipment.py
|
|||
- from_location=from_location,
|
||||
- to_location=to_location,
|
||||
- planned_date=today,
|
||||
- moves=[],
|
||||
- )
|
||||
- shipment_moves = []
|
||||
- for move in moves:
|
||||
- product_id, qty = move
|
||||
- product = id2product.setdefault(
|
||||
- product_id, Product(product_id))
|
||||
- shipment.moves.append(Move(
|
||||
- shipment_moves.append(Move(
|
||||
- from_location=from_location,
|
||||
- to_location=to_location,
|
||||
- planned_date=today,
|
||||
|
@ -131,6 +143,7 @@ diff -r 9a0b5b830df9 trytond/trytond/modules/stock_supply/shipment.py
|
|||
- uom=product.default_uom,
|
||||
- company=user_record.company,
|
||||
- ))
|
||||
- shipment.moves = shipment_moves
|
||||
- shipment.save()
|
||||
- shipments.append(shipment)
|
||||
+ # Create a list of moves to create
|
||||
|
@ -185,7 +198,7 @@ diff -r 9a0b5b830df9 trytond/trytond/modules/stock_supply/shipment.py
|
|||
+ shipment.on_change_with_planned_start_date())
|
||||
+ shipments.append(shipment)
|
||||
+ date += datetime.timedelta(1)
|
||||
+ shipments = cls.create([s._save_values for s in shipments])
|
||||
+ cls.save(shipments)
|
||||
cls.wait(shipments)
|
||||
return shipments
|
||||
|
||||
|
|
Loading…
Reference in New Issue