From f33adec29dbfceda1bef194a68b5a8820db8d9b3 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Tue, 13 Aug 2013 16:23:44 +0200 Subject: [PATCH 1/9] [WIP] Change workflow of mrp and add field ready_production which checks if the raw material moves to consume are assigned, change prepare_order_line_procurement with correct params bzr revid: jco@openerp.com-20130813142344-c6n7awvjj796iliu --- addons/mrp/mrp.py | 22 +++++++++++++++++++++- addons/mrp/mrp_workflow.xml | 4 ++-- addons/project_mrp/project_mrp.py | 4 ++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 62e64dbbd59..15d034e0010 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -452,6 +452,25 @@ class mrp_production(osv.osv): result[mrp_production.id] = done / mrp_production.product_qty * 100 return result + def _moves_assigned(self, cr, uid, ids, name, arg, context=None): + """ Test whether all the consume lines are assigned """ + res = True + for production in self.browse(cr, uid, ids, context=context): + states = [x.state != 'assigned' for x in production.move_lines if x] + if any(states) or len(states) == 0: + return False + return res + + + def _mrp_from_move(self, cr, uid, ids, context=None): + """ Return mrp""" + res = [] + for move in self.browse(cr, uid, ids, context=context): + res += self.pool.get("mrp.production").search(cr, uid, [('move_lines', 'in', move.id)], context=context) + return res + + + _columns = { 'name': fields.char('Reference', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}), 'origin': fields.char('Source Document', size=64, readonly=True, states={'draft': [('readonly', False)]}, @@ -510,6 +529,8 @@ class mrp_production(osv.osv): 'cycle_total': fields.function(_production_calc, type='float', string='Total Cycles', multi='workorder', store=True), 'user_id':fields.many2one('res.users', 'Responsible'), 'company_id': fields.many2one('res.company','Company',required=True), + 'ready_production': fields.function(_moves_assigned, type='boolean', store={'stock.move': (_mrp_from_move, ['state'], 10)}), + } _defaults = { 'priority': lambda *a: '1', @@ -554,7 +575,6 @@ class mrp_production(osv.osv): 'move_created_ids2' : [], 'product_lines' : [], 'move_prod_id' : False, - 'picking_id' : False }) return super(mrp_production, self).copy(cr, uid, id, default, context) diff --git a/addons/mrp/mrp_workflow.xml b/addons/mrp/mrp_workflow.xml index 23119bf9490..388dd9039b3 100644 --- a/addons/mrp/mrp_workflow.xml +++ b/addons/mrp/mrp_workflow.xml @@ -43,7 +43,7 @@ True function - action_production_end() + action_production_end() done @@ -70,7 +70,7 @@ - picking_id and picking_id.state=='done' + ready_production diff --git a/addons/project_mrp/project_mrp.py b/addons/project_mrp/project_mrp.py index 08227a8dae0..f9aea33f2fb 100644 --- a/addons/project_mrp/project_mrp.py +++ b/addons/project_mrp/project_mrp.py @@ -123,9 +123,9 @@ class product_product(osv.osv): class sale_order(osv.osv): _inherit = 'sale.order' - def _prepare_order_line_procurement(self, cr, uid, order, line, move_id, date_planned, context=None): + def _prepare_order_line_procurement(self, cr, uid, order, line, group_id=False, context=None): proc_data = super(sale_order, self)._prepare_order_line_procurement(cr, - uid, order, line, move_id, date_planned, context=context) + uid, order, line, group_id = group_id, context=context) proc_data['sale_line_id'] = line.id return proc_data From 794f31aa7626b43a1abf1822ed00c4c07883a0e1 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Tue, 13 Aug 2013 16:52:28 +0200 Subject: [PATCH 2/9] [IMP] Further remove procure_method in product bzr revid: jco@openerp.com-20130813145228-17q4z7rgqs8dwrw0 --- addons/mrp/procurement.py | 3 +-- addons/project_mrp/project_mrp_view.xml | 7 ------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py index 76c9f229fdc..9dad9aa5899 100644 --- a/addons/mrp/procurement.py +++ b/addons/mrp/procurement.py @@ -92,8 +92,7 @@ class procurement_order(osv.osv): def get_phantom_bom_id(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): - if procurement.move_dest_id and procurement.move_dest_id.product_id.supply_method=='produce' \ - and procurement.move_dest_id.product_id.procure_method=='make_to_order': + if procurement.move_dest_id and procurement.move_dest_id.product_id.supply_method=='produce': phantom_bom_id = self.pool.get('mrp.bom').search(cr, uid, [ ('product_id', '=', procurement.move_dest_id.product_id.id), ('bom_id', '=', False), diff --git a/addons/project_mrp/project_mrp_view.xml b/addons/project_mrp/project_mrp_view.xml index 6539f52155a..302225a24ec 100644 --- a/addons/project_mrp/project_mrp_view.xml +++ b/addons/project_mrp/project_mrp_view.xml @@ -49,13 +49,6 @@ False - -

- When you sell this service to a customer, a task will be - created to follow up the job to do. This task will appear - in the project related to the contract of the sales order. -

-
From 6484c55eee39b38920952b11f821c306807b58bd Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Tue, 13 Aug 2013 17:55:19 +0200 Subject: [PATCH 3/9] [IMP] Remove get_type_from_usage bzr revid: jco@openerp.com-20130813155519-uavabjg8x6z80i64 --- addons/stock/stock.py | 10 ---------- addons/stock_location/stock_location.py | 1 - 2 files changed, 11 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index a8d4ea6a802..9788a0c33d8 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1510,16 +1510,6 @@ class stock_move(osv.osv): }, context=context) return new_move - def get_type_from_usage(self, cr, uid, location, location_dest, context=None): - ''' - Returns the type to be chosen based on the usages of the locations - ''' - if location.usage == 'internal' and location_dest.usage in ['supplier', 'customer']: - return 'out' - if location.usage in ['supplier', 'customer'] and location_dest.usage == 'internal' : - return 'in' - return 'internal' - class stock_inventory(osv.osv): _name = "stock.inventory" _description = "Inventory" diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py index 26992746edb..668b80ae72a 100644 --- a/addons/stock_location/stock_location.py +++ b/addons/stock_location/stock_location.py @@ -102,7 +102,6 @@ class stock_location_path(osv.osv): 'date_expected': newdate, 'picking_id': False, 'picking_type_id': rule.picking_type_id and rule.picking_type_id.id or False, - 'type': move_obj.get_type_from_usage(cr, uid, move.location_id, move.location_dest_id, context=context), 'rule_id': rule.id, 'propagate': rule.propagate, }) From 3f44214b4e59a12281551756fb5f8f3f8155dca2 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Tue, 13 Aug 2013 18:16:54 +0200 Subject: [PATCH 4/9] [IMP] typo product_id instead of product_it bzr revid: jco@openerp.com-20130813161654-pylu2asod3kwwp3m --- addons/project_mrp/project_mrp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/project_mrp/project_mrp.py b/addons/project_mrp/project_mrp.py index f9aea33f2fb..e00883ed764 100644 --- a/addons/project_mrp/project_mrp.py +++ b/addons/project_mrp/project_mrp.py @@ -32,7 +32,7 @@ class procurement_order(osv.osv): } def _is_procurement_task(self, cr, uid, procurement, context=None): - return procurement.product_id.type == 'service' and procurement.product_it.auto_create_task or False + return procurement.product_id.type == 'service' and procurement.product_id.auto_create_task or False def _assign(self, cr, uid, procurement, context=None): res = super(procurement_order, self)._assign(cr, uid, procurement, context=context) From 28e8d5df95794c76ced4e8a6384deab574e61547 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Tue, 13 Aug 2013 18:31:15 +0200 Subject: [PATCH 5/9] [IMP] fields_id is required in ir_property bzr revid: jco@openerp.com-20130813163115-xy3z861ww0bdftot --- addons/l10n_ca/account_chart_template_en.xml | 2 ++ addons/l10n_ca/account_chart_template_fr.xml | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/l10n_ca/account_chart_template_en.xml b/addons/l10n_ca/account_chart_template_en.xml index 635fa7b8bb1..24505dac8e6 100644 --- a/addons/l10n_ca/account_chart_template_en.xml +++ b/addons/l10n_ca/account_chart_template_en.xml @@ -16,11 +16,13 @@ + + diff --git a/addons/l10n_ca/account_chart_template_fr.xml b/addons/l10n_ca/account_chart_template_fr.xml index 7d1cc0a9ae2..169f6c45f1e 100644 --- a/addons/l10n_ca/account_chart_template_fr.xml +++ b/addons/l10n_ca/account_chart_template_fr.xml @@ -15,11 +15,13 @@ + - + + From 5326a67564cc5cbdcc65804010ee4a0985d5960b Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Tue, 13 Aug 2013 21:12:33 +0200 Subject: [PATCH 6/9] [IMP] Invoice directly should work differently as partial picking wizard disappeared bzr revid: jco@openerp.com-20130813191233-1b851jczqu7a15bb --- .../wizard/stock_invoice.py | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/addons/stock_invoice_directly/wizard/stock_invoice.py b/addons/stock_invoice_directly/wizard/stock_invoice.py index ba41de626da..5c126f33374 100644 --- a/addons/stock_invoice_directly/wizard/stock_invoice.py +++ b/addons/stock_invoice_directly/wizard/stock_invoice.py @@ -21,29 +21,29 @@ from openerp.osv import fields, osv -class invoice_directly(osv.osv_memory): - _inherit = 'stock.partial.picking' - - def do_partial(self, cr, uid, ids, context=None): - """Launch Create invoice wizard if invoice state is To be Invoiced, - after processing the partial picking. - """ - if context is None: context = {} - result = super(invoice_directly, self).do_partial(cr, uid, ids, context) - partial = self.browse(cr, uid, ids[0], context) - context.update(active_model='stock.picking', - active_ids=[partial.picking_id.id]) - if partial.picking_id.invoice_state == '2binvoiced': - return { - 'name': 'Create Invoice', - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'stock.invoice.onshipping', - 'type': 'ir.actions.act_window', - 'target': 'new', - 'context': context - } - return {'type': 'ir.actions.act_window_close'} +# class invoice_directly(osv.osv_memory): +# _inherit = 'stock.partial.picking' +# +# def do_partial(self, cr, uid, ids, context=None): +# """Launch Create invoice wizard if invoice state is To be Invoiced, +# after processing the partial picking. +# """ +# if context is None: context = {} +# result = super(invoice_directly, self).do_partial(cr, uid, ids, context) +# partial = self.browse(cr, uid, ids[0], context) +# context.update(active_model='stock.picking', +# active_ids=[partial.picking_id.id]) +# if partial.picking_id.invoice_state == '2binvoiced': +# return { +# 'name': 'Create Invoice', +# 'view_type': 'form', +# 'view_mode': 'form', +# 'res_model': 'stock.invoice.onshipping', +# 'type': 'ir.actions.act_window', +# 'target': 'new', +# 'context': context +# } +# return {'type': 'ir.actions.act_window_close'} # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From b8220056f775477720fb9f560b4b88a3ed1521bd Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Wed, 14 Aug 2013 16:14:26 +0530 Subject: [PATCH 7/9] [IMP] remove procure_method in yml that not in procurement anymore bzr revid: rma@tinyerp.com-20130814104426-o8w3mu3dxtgd17d9 --- addons/sale_stock/test/sale_order_onchange.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/sale_stock/test/sale_order_onchange.yml b/addons/sale_stock/test/sale_order_onchange.yml index 1026e5627c3..c97acdcb8c9 100644 --- a/addons/sale_stock/test/sale_order_onchange.yml +++ b/addons/sale_stock/test/sale_order_onchange.yml @@ -4,7 +4,6 @@ !record {model: product.product, id: product_onchange1}: name: 'Devil Worship Book' list_price: 66.6 - procure_method: 'make_to_order' - Now i create a sale order that uses my new product - From d565a50c35babe211ebd9a5e0abc5f6c1f937e52 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Wed, 14 Aug 2013 14:13:49 +0200 Subject: [PATCH 8/9] [IMP] steps procrule bzr revid: jco@openerp.com-20130814121349-go02w2gs0bhi46dj --- addons/stock/test/procrule.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/stock/test/procrule.yml b/addons/stock/test/procrule.yml index a8baad650e8..d1762ae4806 100644 --- a/addons/stock/test/procrule.yml +++ b/addons/stock/test/procrule.yml @@ -1,5 +1,11 @@ - - Create new delivery order from output -> customers + Create new global procurement rule from Stock -> Output +- + !record {model: procurement.rule, ref:} + location_id: stock + location_dest_id: output +- + Create Delivery Order from Output -> Customer - !record {model: stock.picking, ref:} - From 290d3b31ccaa0cc54411357c8f7da99b8943f7bd Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Wed, 14 Aug 2013 17:44:45 +0530 Subject: [PATCH 9/9] [IMP] remove extra assert bzr revid: rma@tinyerp.com-20130814121445-i29uhxxd43rdzw2g --- addons/sale_stock/test/sale_order_onchange.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/sale_stock/test/sale_order_onchange.yml b/addons/sale_stock/test/sale_order_onchange.yml index c97acdcb8c9..1c3a4a5b4c3 100644 --- a/addons/sale_stock/test/sale_order_onchange.yml +++ b/addons/sale_stock/test/sale_order_onchange.yml @@ -18,4 +18,3 @@ !assert {model: sale.order, id: sale_order_onchange1, string: The onchange function of product was not correctly triggered}: - order_line[0].name == u'Devil Worship Book' - order_line[0].price_unit == 66.6 - - order_line[0].type == 'make_to_order'