[ADD] sale_mrp: Task ID-819: * sale/mrp.py content a good feature, it should be put in a module that depends on both sale and mrp: sale_mrp.
bzr revid: uco@tinyerp.com-20100527132615-jwn07v3lo3thgx79
This commit is contained in:
parent
c45aa850a7
commit
007a3279b5
|
@ -0,0 +1,24 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# OpenERP, Open Source Management Solution
|
||||||
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
import sale_mrp
|
||||||
|
|
||||||
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,44 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# OpenERP, Open Source Management Solution
|
||||||
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': 'Sales and MRP Management',
|
||||||
|
'version': '1.0',
|
||||||
|
'category': 'Generic Modules/Sales & MRP',
|
||||||
|
'description': """
|
||||||
|
This module provides facility to the user to install mrp and sale modules
|
||||||
|
at a time. It is basically used when we want to keep track of production
|
||||||
|
orders generated from sale orders.
|
||||||
|
""",
|
||||||
|
'author': 'Tiny',
|
||||||
|
'website': 'http://www.openerp.com',
|
||||||
|
'depends': ['mrp', 'sale'],
|
||||||
|
'init_xml': [],
|
||||||
|
'update_xml': [
|
||||||
|
'sale_mrp_view.xml',
|
||||||
|
],
|
||||||
|
'demo_xml': [],
|
||||||
|
'installable': True,
|
||||||
|
'active': False,
|
||||||
|
'certificate': '',
|
||||||
|
}
|
||||||
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,79 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# OpenERP, Open Source Management Solution
|
||||||
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
from osv import osv, fields
|
||||||
|
|
||||||
|
class mrp_production(osv.osv):
|
||||||
|
_inherit = 'mrp.production'
|
||||||
|
|
||||||
|
def _ref_calc(self, cr, uid, ids, field_names=None, arg=False, context={}):
|
||||||
|
""" Finds reference of sale order for production order.
|
||||||
|
@param field_names: Names of fields.
|
||||||
|
@param arg: User defined arguments
|
||||||
|
@return: Dictionary of values.
|
||||||
|
"""
|
||||||
|
if not field_names:
|
||||||
|
field_names=[]
|
||||||
|
res = {}
|
||||||
|
for id in ids:
|
||||||
|
res[id] = {}.fromkeys(field_names, False)
|
||||||
|
for f in field_names:
|
||||||
|
field_name = False
|
||||||
|
if f=='sale_name':
|
||||||
|
field_name = 'name'
|
||||||
|
if f=='sale_ref':
|
||||||
|
field_name = 'client_order_ref'
|
||||||
|
for key, value in self._get_sale_ref(cr, uid, ids, field_name).items():
|
||||||
|
res[key][f] = value
|
||||||
|
return res
|
||||||
|
|
||||||
|
def _get_sale_ref(self, cr, uid, ids, field_name=False):
|
||||||
|
move_obj=self.pool.get('stock.move')
|
||||||
|
|
||||||
|
def get_parent_move(move_id):
|
||||||
|
move = move_obj.browse(cr, uid, move_id)
|
||||||
|
if move.move_dest_id:
|
||||||
|
return get_parent_move(move.move_dest_id.id)
|
||||||
|
return move_id
|
||||||
|
|
||||||
|
productions = self.read(cr, uid, ids, ['id','move_prod_id'])
|
||||||
|
res={}
|
||||||
|
for production in productions:
|
||||||
|
res[production['id']] = False
|
||||||
|
if production.get('move_prod_id',False):
|
||||||
|
parent_move_line = get_parent_move(production['move_prod_id'][0])
|
||||||
|
if parent_move_line:
|
||||||
|
move = move_obj.browse(cr,uid,parent_move_line)
|
||||||
|
if field_name == 'name':
|
||||||
|
res[production['id']] = move.sale_line_id and move.sale_line_id.order_id.name or False
|
||||||
|
if field_name=='client_order_ref':
|
||||||
|
res[production['id']] = move.sale_line_id and move.sale_line_id.order_id.client_order_ref or False
|
||||||
|
return res
|
||||||
|
|
||||||
|
_columns = {
|
||||||
|
'sale_name': fields.function(_ref_calc, method=True, multi='sale_name', type='char', string='Sale Name', help='Indicate the name of sale order.'),
|
||||||
|
'sale_ref': fields.function(_ref_calc, method=True, multi='sale_ref', type='char', string='Sale Reference', help='Indicate the Customer Reference from sale order.'),
|
||||||
|
}
|
||||||
|
|
||||||
|
mrp_production()
|
||||||
|
|
||||||
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<record id="view_mrp_production_form" model="ir.ui.view">
|
||||||
|
<field name="name">mrp.production.form</field>
|
||||||
|
<field name="model">mrp.production</field>
|
||||||
|
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="/form/notebook/page/field[@name='move_prod_id']" position="after">
|
||||||
|
<field name="sale_name" groups="base.group_extended"/>
|
||||||
|
<field name="sale_ref" groups="base.group_extended"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</openerp>
|
Loading…
Reference in New Issue