Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
423 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:alt: License | ||
|
||
Procurement Improvement - supply method | ||
======================================= | ||
|
||
This module aims to add more flexibility on procurement management. | ||
* Allowing planner changing the supply method on the procurement order level | ||
by adding a new field supply_method for planner to modify. | ||
|
||
* Allowing planner changing the procurement method and supply method | ||
before the procurement order is running. | ||
|
||
Business case: | ||
One company might purchase from one company or produce in another company | ||
for the same product, the planner can change the supply method | ||
on the procurement order level instead of having two products | ||
with different supply methods. | ||
|
||
Please note that this module re-defines the field: procure_method | ||
which is defined in module: procurement. | ||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to: | ||
|
||
* have basic modules installed (sale, mrp, procurement, purchase) | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
* No specific configuration needed. | ||
|
||
Usage | ||
===== | ||
|
||
|
||
For further information, please visit: | ||
|
||
* https://www.odoo.com/forum/help-1 | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
|
||
Credits | ||
======= | ||
|
||
|
||
Contributors | ||
------------ | ||
|
||
* Alex Duan <alex.duan@elico-corp.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: http://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: http://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization | ||
whose mission is to support the collaborative development of Odoo features | ||
and promote its widespread use. | ||
|
||
To contribute to this module, please visit http://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Copyright (C) 2010-2015 Elico Corp (<http://www.elico-corp.com>) | ||
# Alex Duan <alex.duan@elico-corp.com> | ||
# | ||
# 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/>. | ||
# | ||
############################################################################## | ||
from . import procurement | ||
from . import mrp | ||
from . import sale |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Copyright (C) 2010-2015 Elico Corp (<http://www.elico-corp.com>) | ||
# Alex Duan <alex.duan@elico-corp.com> | ||
# | ||
# 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': 'Procurement Improvement - supply method', | ||
'version': '1.0', | ||
'author': 'Elico Corp, Odoo Community Association (OCA)', | ||
'website': 'www.openerp.net.cn', | ||
'category': 'Generic Modules/Production', | ||
'depends': ['procurement', 'sale', 'mrp', 'purchase'], | ||
'description': """ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:alt: License | ||
Procurement Improvement - supply method | ||
======================================= | ||
This module aims to add more flexibility on procurement management. | ||
* Allowing planner changing the supply method on the procurement order level | ||
by adding a new field supply_method for planner to modify. | ||
* Allowing planner changing the procurement method and supply method | ||
before the procurement order is running. | ||
Business case: | ||
One company might purchase from one company or produce in another company | ||
for the same product, the planner can change the supply method | ||
on the procurement order level instead of having two products | ||
with different supply methods. | ||
Please note that this module re-defines the field: procure_method | ||
which is defined in module: procurement. | ||
Installation | ||
============ | ||
To install this module, you need to: | ||
* have basic modules installed (sale, mrp, procurement, purchase) | ||
Configuration | ||
============= | ||
To configure this module, you need to: | ||
* No specific configuration needed. | ||
Usage | ||
===== | ||
For further information, please visit: | ||
* https://www.odoo.com/forum/help-1 | ||
Known issues / Roadmap | ||
====================== | ||
Credits | ||
======= | ||
Contributors | ||
------------ | ||
* Alex Duan <alex.duan@elico-corp.com> | ||
Maintainer | ||
---------- | ||
.. image:: http://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: http://odoo-community.org | ||
This module is maintained by the OCA. | ||
OCA, or the Odoo Community Association, is a nonprofit organization | ||
whose mission is to support the collaborative development of Odoo features | ||
and promote its widespread use. | ||
To contribute to this module, please visit http://odoo-community.org. | ||
""", | ||
'data': [ | ||
'procurement_supply_method_views.xml', | ||
], | ||
'installable': True, | ||
} | ||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Copyright (C) 2010-2015 Elico Corp (<http://www.elico-corp.com>) | ||
# Alex Duan <alex.duan@elico-corp.com> | ||
# | ||
# 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/>. | ||
# | ||
############################################################################## | ||
from openerp.osv import orm | ||
|
||
|
||
class MrpProduction(orm.Model): | ||
_inherit = 'mrp.production' | ||
|
||
def _hook_create_post_procurement( | ||
self, cr, uid, production, procurement_id, context=None): | ||
'''write back the supply_method to the procurement order''' | ||
|
||
if procurement_id: | ||
procurement_obj = self.pool.get('procurement.order') | ||
procurement_order = procurement_obj.browse( | ||
cr, uid, procurement_id, context=context) | ||
product_id = procurement_order.product_id | ||
if not procurement_order.supply_method: | ||
supply_method = product_id.supply_method | ||
procurement_order.write( | ||
{'supply_method': supply_method}, context=context) | ||
return super(MrpProduction, self)._hook_create_post_procurement( | ||
cr, uid, production, procurement_id, context=context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# Copyright (C) 2010-2015 Elico Corp (<http://www.elico-corp.com>) | ||
# Alex Duan <alex.duan@elico-corp.com> | ||
# | ||
# 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/>. | ||
# | ||
############################################################################## | ||
|
||
from osv import osv, fields | ||
|
||
|
||
class ProcurementOrder(osv.osv): | ||
""" | ||
Procurement Orders | ||
""" | ||
_inherit = "procurement.order" | ||
_columns = { | ||
'supply_method': fields.selection( | ||
[('produce', 'Produce'), ('buy', 'Buy')], | ||
'Supply method', | ||
states={'draft': [('readonly', False)], | ||
'confirmed': [('readonly', False)], | ||
'exception': [('readonly', False)]}, | ||
readonly=True), | ||
|
||
# make this field editable when in state draft,confirmed and exception. | ||
'procure_method': fields.selection( | ||
[('make_to_stock', 'Make to Stock'), | ||
('make_to_order', 'Make to Order')], | ||
'Procurement Method', | ||
states={'draft': [('readonly', False)], | ||
'confirmed': [('readonly', False)], | ||
'exception': [('readonly', False)]}, | ||
readonly=True, required=True, | ||
help="If you encode manually a Procurement," | ||
" you probably want to use a make to order method."), | ||
|
||
} | ||
|
||
def init(self, cr): | ||
'''initializes the supply_method field for existing data | ||
when this module is first installed. | ||
NOTE: this method will be executed | ||
when this module is installed or upgraded.''' | ||
|
||
cr.execute('update procurement_order ' | ||
'set supply_method = pt.supply_method ' | ||
'from product_product pp, product_template pt ' | ||
'where procurement_order.supply_method is null ' | ||
'and procurement_order.product_id = pp.id ' | ||
'and pp.product_tmpl_id = pt.id') | ||
|
||
def check_produce(self, cr, uid, ids, context=None): | ||
""" Checks product supply method. | ||
Checking the supply_method on the procurement order first. | ||
@return: True or Product Id. | ||
""" | ||
for procurement in self.browse(cr, uid, ids, context=context): | ||
supply_method = procurement.supply_method | ||
if supply_method: | ||
if supply_method != 'produce': | ||
return False | ||
elif supply_method == 'service': | ||
res = self.check_produce_service( | ||
cr, uid, procurement, context) | ||
else: | ||
res = self.check_produce_product( | ||
cr, uid, procurement, context) | ||
if not res: | ||
return False | ||
return True | ||
else: | ||
return super(ProcurementOrder, self).check_produce( | ||
cr, uid, ids, context=context) | ||
|
||
def check_buy(self, cr, uid, ids, context=None): | ||
""" Checks supply method. | ||
Checking the supply_method on the procurement order first. | ||
@return: True or Product Id. | ||
""" | ||
for procurement in self.browse(cr, uid, ids, context=context): | ||
supply_method = procurement.supply_method | ||
if supply_method: | ||
if supply_method != 'buy': | ||
return False | ||
else: | ||
return True | ||
else: | ||
return super(ProcurementOrder, self).check_buy( | ||
cr, uid, ids, context=context) | ||
|
||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
28 changes: 28 additions & 0 deletions
28
procurement_supply_method/procurement_supply_method_views.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" ?> | ||
<openerp> | ||
<data> | ||
<record model="ir.ui.view" id="procurement_tree_view_supplymethod"> | ||
<field name="name">procurement_tree_view_supplymethod</field> | ||
<field name="model">procurement.order</field> | ||
<field name="inherit_id" ref="procurement.procurement_tree_view"/> | ||
<field name="type">tree</field> | ||
<field name="arch" type="xml"> | ||
<field name="procure_method" position="after"> | ||
<field name="supply_method" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record model="ir.ui.view" id="procurement_form_view_supplymethod"> | ||
<field name="name">procurement_form_view.supplymethod</field> | ||
<field name="model">procurement.order</field> | ||
<field name="inherit_id" ref="procurement.procurement_form_view"/> | ||
<field name="type">form</field> | ||
<field name="arch" type="xml"> | ||
<field name='procure_method' position="after"> | ||
<field name="supply_method"/> | ||
</field> | ||
</field> | ||
</record> | ||
</data> | ||
</openerp> |
Oops, something went wrong.