Merge supply into one wizard
issue6147 review34601002
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Merge supply into one wizard
|
||||
* Do not create production request if other order point exists
|
||||
|
||||
Version 4.2.0 - 2016-11-28
|
||||
|
||||
+1
-2
@@ -13,9 +13,8 @@ def register():
|
||||
LocationLeadTime,
|
||||
Configuration,
|
||||
Production,
|
||||
CreateProductionRequestStart,
|
||||
Product,
|
||||
module='stock_supply_production', type_='model')
|
||||
Pool.register(
|
||||
CreateProductionRequest,
|
||||
StockSupply,
|
||||
module='stock_supply_production', type_='wizard')
|
||||
|
||||
+1
-1
@@ -22,6 +22,6 @@ It adds a new type of Order Point:
|
||||
quantity is reached at any time on the warehouse it will result in a
|
||||
production request.
|
||||
|
||||
The production requests are created by the schedulers with respect to stock
|
||||
The production requests are created by the supply wizard with respect to stock
|
||||
levels and existing requests. The stock levels are computed on the supply
|
||||
period define in the production configuration.
|
||||
|
||||
+2
-55
@@ -3,14 +3,12 @@
|
||||
import datetime
|
||||
from collections import defaultdict
|
||||
|
||||
from trytond.model import ModelView, fields
|
||||
from trytond.model import fields
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.wizard import Wizard, StateView, StateAction, Button
|
||||
from trytond.tools import grouped_slice
|
||||
|
||||
__all__ = ['Configuration', 'Production',
|
||||
'CreateProductionRequestStart', 'CreateProductionRequest']
|
||||
__all__ = ['Configuration', 'Production']
|
||||
|
||||
|
||||
class Configuration:
|
||||
@@ -119,8 +117,6 @@ class Production:
|
||||
req.save()
|
||||
req.set_moves()
|
||||
requests.append(req)
|
||||
if requests:
|
||||
cls.generate_requests(False, warehouses)
|
||||
return requests
|
||||
|
||||
@classmethod
|
||||
@@ -211,52 +207,3 @@ class Production:
|
||||
current_qties[product_id] += qty
|
||||
|
||||
return shortages
|
||||
|
||||
|
||||
class CreateProductionRequestStart(ModelView):
|
||||
'Create Production Request'
|
||||
__name__ = 'production.create_request.start'
|
||||
|
||||
|
||||
class CreateProductionRequest(Wizard):
|
||||
'Create Production Requests'
|
||||
__name__ = 'production.create_request'
|
||||
start = StateView('production.create_request.start',
|
||||
'stock_supply_production.production_create_request_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Create', 'create_', 'tryton-ok', default=True),
|
||||
])
|
||||
create_ = StateAction('stock_supply_production.act_production_request')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(CreateProductionRequest, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'late_productions': 'There are some late productions.',
|
||||
})
|
||||
|
||||
@property
|
||||
def _requests_parameters(self):
|
||||
return {}
|
||||
|
||||
def do_create_(self, action):
|
||||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
Move = pool.get('stock.move')
|
||||
Production = pool.get('production')
|
||||
|
||||
today = Date.today()
|
||||
if Move.search([
|
||||
('from_location.type', '=', 'production'),
|
||||
('to_location.type', '=', 'storage'),
|
||||
('state', '=', 'draft'),
|
||||
('planned_date', '<', today),
|
||||
], order=[]):
|
||||
self.raise_user_warning('%s@%s' % (self.__name__, today),
|
||||
'late_productions')
|
||||
|
||||
Production.generate_requests(**self._requests_parameters)
|
||||
return action, {}
|
||||
|
||||
def transition_create_(self):
|
||||
return 'end'
|
||||
|
||||
@@ -11,18 +11,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="name">production_configuration_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.wizard" id="act_production_request_create">
|
||||
<field name="name">Create Production Requests</field>
|
||||
<field name="wiz_name">production.create_request</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view"
|
||||
id="production_create_request_start_view_form">
|
||||
<field name="model">production.create_request.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">production_create_request_start_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.act_window" id="act_production_request">
|
||||
<field name="name">Request Productions</field>
|
||||
<field name="res_model">production</field>
|
||||
@@ -42,34 +30,5 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="act_window" ref="act_production_request"/>
|
||||
</record>
|
||||
|
||||
<menuitem parent="production.menu_production_list" sequence="5"
|
||||
action="act_production_request_create"
|
||||
id="menu_production_request_create"/>
|
||||
|
||||
<record model="res.user" id="user_generate_request">
|
||||
<field name="login">user_cron_production_request</field>
|
||||
<field name="name">Cron Production Request</field>
|
||||
<field name="signature"></field>
|
||||
<field name="active" eval="False"/>
|
||||
</record>
|
||||
<record model="res.user-res.group"
|
||||
id="user_generate_request_group_production">
|
||||
<field name="user" ref="user_generate_request"/>
|
||||
<field name="group" ref="production.group_production"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.cron" id="cron_generate_request">
|
||||
<field name="name">Generate Production Requests</field>
|
||||
<field name="request_user" ref="res.user_admin"/>
|
||||
<field name="user" ref="user_generate_request"/>
|
||||
<field name="active" eval="True"/>
|
||||
<field name="interval_number" eval="1"/>
|
||||
<field name="interval_type">days</field>
|
||||
<field name="number_calls" eval="-1"/>
|
||||
<field name="repeat_missed" eval="False"/>
|
||||
<field name="model">production</field>
|
||||
<field name="function">generate_requests</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
||||
@@ -4,8 +4,9 @@ import datetime
|
||||
|
||||
from trytond.pyson import Eval, If
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.wizard import StateAction
|
||||
|
||||
__all__ = ['OrderPoint', 'LocationLeadTime']
|
||||
__all__ = ['OrderPoint', 'LocationLeadTime', 'StockSupply']
|
||||
|
||||
|
||||
class OrderPoint:
|
||||
@@ -61,3 +62,49 @@ class LocationLeadTime:
|
||||
extra = super(LocationLeadTime, cls)._get_extra_lead_times()
|
||||
extra.append(datetime.timedelta(Configuration(1).supply_period or 0))
|
||||
return extra
|
||||
|
||||
|
||||
class StockSupply:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'stock.supply'
|
||||
|
||||
production = StateAction('stock_supply_production.act_production_request')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(StockSupply, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'late_productions': 'There are some late productions.',
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def types(cls):
|
||||
return super(StockSupply, cls).types() + ['production']
|
||||
|
||||
def transition_create_(self):
|
||||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
Move = pool.get('stock.move')
|
||||
today = Date.today()
|
||||
if Move.search([
|
||||
('from_location.type', '=', 'production'),
|
||||
('to_location.type', '=', 'storage'),
|
||||
('state', '=', 'draft'),
|
||||
('planned_date', '<', today),
|
||||
], order=[]):
|
||||
self.raise_user_warning('%s@%s' % (self.__name__, today),
|
||||
'late_productions')
|
||||
return super(StockSupply, self).transition_create_()
|
||||
|
||||
@property
|
||||
def _production_parameters(self):
|
||||
return {}
|
||||
|
||||
def generate_production(self, clean):
|
||||
pool = Pool()
|
||||
Production = pool.get('production')
|
||||
return Production.generate_requests(
|
||||
clean=clean, **self._production_parameters)
|
||||
|
||||
def transition_production(self):
|
||||
return self.next_action('production')
|
||||
|
||||
@@ -63,7 +63,7 @@ The is no production request::
|
||||
|
||||
Create production request::
|
||||
|
||||
>>> create_pr = Wizard('production.create_request')
|
||||
>>> create_pr = Wizard('stock.supply')
|
||||
>>> create_pr.execute('create_')
|
||||
|
||||
There is now a production request::
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?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 col="2">
|
||||
<image name="tryton-dialog-information" xexpand="0" xfill="0"/>
|
||||
<label string="Create Production Requests?" id="create"
|
||||
yalign="0.0" xalign="0.0" xexpand="1"/>
|
||||
</form>
|
||||
Reference in New Issue
Block a user