Add issue5575 in 3.4 series - stock_supply: Add configuration for the supply period
This commit is contained in:
parent
58565f847c
commit
e0eb74c2f5
|
@ -0,0 +1,119 @@
|
|||
diff -r 67d5653c0e7a trytond/trytond/modules/stock_supply/__init__.py
|
||||
--- a/trytond/trytond/modules/stock_supply/__init__.py Thu Jun 02 12:40:58 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock_supply/__init__.py Thu Jun 02 12:44:08 2016 +0200
|
||||
@@ -13,6 +13,8 @@
|
||||
Pool.register(
|
||||
OrderPoint,
|
||||
Product,
|
||||
+ ProductSupplier,
|
||||
+ PurchaseConfiguration,
|
||||
PurchaseRequest,
|
||||
CreatePurchaseRequestStart,
|
||||
CreatePurchaseAskParty,
|
||||
diff -r 67d5653c0e7a trytond/trytond/modules/stock_supply/product.py
|
||||
--- a/trytond/trytond/modules/stock_supply/product.py Thu Jun 02 12:40:58 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock_supply/product.py Thu Jun 02 12:44:08 2016 +0200
|
||||
@@ -1,9 +1,9 @@
|
||||
#This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
#this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import fields
|
||||
-from trytond.pool import PoolMeta
|
||||
+from trytond.pool import Pool, PoolMeta
|
||||
|
||||
-__all__ = ['Product']
|
||||
+__all__ = ['Product', 'ProductSupplier']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
@@ -11,3 +11,15 @@
|
||||
__name__ = "product.product"
|
||||
order_points = fields.One2Many(
|
||||
'stock.order_point', 'product', 'Order Points')
|
||||
+
|
||||
+
|
||||
+class ProductSupplier:
|
||||
+ __metaclass__ = PoolMeta
|
||||
+ __name__ = 'purchase.product_supplier'
|
||||
+
|
||||
+ def get_supply_period(self):
|
||||
+ 'Return the supply period for the purchase request in days'
|
||||
+ pool = Pool()
|
||||
+ Configuration = pool.get('purchase.configuration')
|
||||
+ supply_period = Configuration(1).supply_period
|
||||
+ return int(Configuration(1).supply_period) if supply_period else 1
|
||||
diff -r 67d5653c0e7a trytond/trytond/modules/stock_supply/purchase_request.py
|
||||
--- a/trytond/trytond/modules/stock_supply/purchase_request.py Thu Jun 02 12:40:58 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock_supply/purchase_request.py Thu Jun 02 12:44:08 2016 +0200
|
||||
@@ -10,10 +10,10 @@
|
||||
Button
|
||||
from trytond.pyson import If, In, Eval, Get
|
||||
from trytond.transaction import Transaction
|
||||
-from trytond.pool import Pool
|
||||
+from trytond.pool import Pool, PoolMeta
|
||||
from trytond.tools import grouped_slice
|
||||
|
||||
-__all__ = ['PurchaseRequest',
|
||||
+__all__ = ['PurchaseRequest', 'PurchaseConfiguration',
|
||||
'CreatePurchaseRequestStart', 'CreatePurchaseRequest',
|
||||
'CreatePurchaseAskParty', 'CreatePurchase']
|
||||
|
||||
@@ -21,6 +21,17 @@
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}
|
||||
DEPENDS = ['state']
|
||||
+__metaclass__ = PoolMeta
|
||||
+
|
||||
+
|
||||
+class PurchaseConfiguration:
|
||||
+ __name__ = 'purchase.configuration'
|
||||
+ supply_period = fields.Property(fields.Numeric('Supply Period',
|
||||
+ help='In number of days', required=True))
|
||||
+
|
||||
+ @classmethod
|
||||
+ def default_supply_period(cls):
|
||||
+ return 1
|
||||
|
||||
|
||||
class PurchaseRequest(ModelSQL, ModelView):
|
||||
@@ -326,9 +337,8 @@
|
||||
|
||||
for product_supplier in product.product_suppliers:
|
||||
supply_date = product_supplier.compute_supply_date(date=today)
|
||||
- # TODO next_day is by default today + 1 but should depends
|
||||
- # on the CRON activity
|
||||
- next_day = today + datetime.timedelta(1)
|
||||
+ next_day = today + datetime.timedelta(
|
||||
+ product_supplier.get_supply_period())
|
||||
next_supply_date = product_supplier.compute_supply_date(
|
||||
date=next_day)
|
||||
if (not min_date) or supply_date < min_date:
|
||||
diff -r 67d5653c0e7a trytond/trytond/modules/stock_supply/purchase_request.xml
|
||||
--- a/trytond/trytond/modules/stock_supply/purchase_request.xml Thu Jun 02 12:40:58 2016 +0200
|
||||
+++ b/trytond/trytond/modules/stock_supply/purchase_request.xml Thu Jun 02 12:44:08 2016 +0200
|
||||
@@ -3,6 +3,12 @@
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
+ <record model="ir.ui.view" id="purchase_configuration_view_form">
|
||||
+ <field name="model">purchase.configuration</field>
|
||||
+ <field name="inherit"
|
||||
+ ref="purchase.purchase_configuration_view_form"/>
|
||||
+ <field name="name">purchase_configuration_form</field>
|
||||
+ </record>
|
||||
|
||||
<record model="res.group" id="group_purchase_request">
|
||||
<field name="name">Purchase Request</field>
|
||||
diff -r 67d5653c0e7a trytond/trytond/modules/stock_supply/view/purchase_configuration_form.xml
|
||||
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
||||
+++ b/trytond/trytond/modules/stock_supply/view/purchase_configuration_form.xml Thu Jun 02 12:44:08 2016 +0200
|
||||
@@ -0,0 +1,10 @@
|
||||
+<?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. -->
|
||||
+<data>
|
||||
+ <xpath expr="/form/field[@name='purchase_invoice_method']"
|
||||
+ position="after">
|
||||
+ <label name="supply_period"/>
|
||||
+ <field name="supply_period"/>
|
||||
+ </xpath>
|
||||
+</data>
|
Loading…
Reference in New Issue