Allow to define effective date of productions

issue3579
review2871002
This commit is contained in:
Sergi Almacellas Abellana
2014-01-30 19:22:02 +01:00
parent 7c382c5e7c
commit 6dbddb52a4
4 changed files with 43 additions and 4 deletions
+2
View File
@@ -1,3 +1,5 @@
* Allow to define effective date of productions
Version 3.0.0 - 2013-10-21
* Bug fixes (see mercurial logs for details)
* Add calendar view
+6 -2
View File
@@ -30,7 +30,11 @@ class Production(Workflow, ModelSQL, ModelView):
'readonly': ~Eval('state').in_(['request', 'draft']),
},
depends=['state'])
effective_date = fields.Date('Effective Date', readonly=True)
effective_date = fields.Date('Effective Date',
states={
'readonly': Eval('state').in_(['cancel', 'done']),
},
depends=['state'])
company = fields.Many2One('company.company', 'Company', required=True,
states={
'readonly': ~Eval('state').in_(['request', 'draft']),
@@ -545,7 +549,7 @@ class Production(Workflow, ModelSQL, ModelView):
Move = pool.get('stock.move')
Date = pool.get('ir.date')
Move.do([m for p in productions for m in p.outputs])
cls.write(productions, {
cls.write([p for p in productions if not p.effective_date], {
'effective_date': Date.today(),
})
+7
View File
@@ -33,3 +33,10 @@ class Move:
readonly=True, select=True, ondelete='CASCADE',
domain=[('company', '=', Eval('company'))],
depends=['company'])
def set_effective_date(self):
if not self.effective_date and self.production_input:
self.effective_date = self.production_input.effective_date
if not self.effective_date and self.production_output:
self.effective_date = self.production_output.effective_date
super(Move, self).set_effective_date()
+28 -2
View File
@@ -13,6 +13,7 @@ Imports::
>>> from decimal import Decimal
>>> from proteus import config, Model, Wizard
>>> today = datetime.date.today()
>>> yesterday = today - relativedelta(days=1)
Create database::
@@ -145,11 +146,11 @@ Create an Inventory::
>>> inventory_line1 = InventoryLine()
>>> inventory.lines.append(inventory_line1)
>>> inventory_line1.product = component1
>>> inventory_line1.quantity = 10
>>> inventory_line1.quantity = 20
>>> inventory_line2 = InventoryLine()
>>> inventory.lines.append(inventory_line2)
>>> inventory_line2.product = component2
>>> inventory_line2.quantity = 5
>>> inventory_line2.quantity = 6
>>> inventory.save()
>>> Inventory.confirm([inventory.id], config.context)
>>> inventory.state
@@ -182,12 +183,37 @@ Make a production::
>>> production.reload()
>>> all(i.state == 'done' for i in production.inputs)
True
>>> all(i.effective_date == today for i in production.inputs)
True
>>> Production.done([production.id], config.context)
>>> production.reload()
>>> output, = production.outputs
>>> output.state
u'done'
>>> output.effective_date == today
True
>>> config._context['locations'] = [storage.id]
>>> product.reload()
>>> product.quantity == 2
True
Make a production with effective date yesterday::
>>> Production = Model.get('production')
>>> production = Production()
>>> production.effective_date = yesterday
>>> production.product = product
>>> production.bom = bom
>>> production.quantity = 2
>>> production.click('wait')
>>> Production.assign_try([production.id], config.context)
True
>>> production.click('run')
>>> production.reload()
>>> all(i.effective_date == yesterday for i in production.inputs)
True
>>> production.click('done')
>>> production.reload()
>>> output, = production.outputs
>>> output.effective_date == yesterday
True