diff options
| author | Simon Lejeune <sle@openerp.com> | 2019-03-27 18:41:41 +0000 |
|---|---|---|
| committer | Simon Lejeune <sle@openerp.com> | 2019-04-03 13:52:22 +0000 |
| commit | d91db5bde6133d9da86893043afbaed8134e4104 (patch) | |
| tree | 6e5ec6a3ba8b4d210ccaa132a345f940db028573 /addons/mrp_subcontracting/__init__.py | |
| parent | 928e3e0a0b3d8bbb4cdf33eed127433ecd195688 (diff) | |
[ADD] mrp_subcontracting
In a few words, it allows to send components to a subcontractor partner
and receive a finished product. The production is managed through classical
manufacturing orders where the raw and finished location is the
subcontracting location. When creating a receipt picking for a
subcontractor partner, the location_id of the moves will be set to the
subcontracting locations by using the property_stock_customer and
property_stock_supplier of the partner. An override of _action_confirm
will create the manufacturing order.
When a subcontracted bom contains tracking, the produce wizard is
available from the picking to record which lots were produced/consumed.
New type on the BoM: subcontract
New type on res.partner: subcontactor
New location per company (we still own the components stored at the
subcontractor so they're still valued)
New routes created to resupply the subcontracting location on order or
not (through a reordering rule).
Override of res.partner to set the property_stock_customer/supplier on
subcontactor partners.
Proper tests were added too.
Joint work with: Arnaud Baes <arb@odoo.com>
task 1831382
Diffstat (limited to 'addons/mrp_subcontracting/__init__.py')
| -rw-r--r-- | addons/mrp_subcontracting/__init__.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/addons/mrp_subcontracting/__init__.py b/addons/mrp_subcontracting/__init__.py new file mode 100644 index 00000000000..be29e5c5628 --- /dev/null +++ b/addons/mrp_subcontracting/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +from . import models +from odoo import api, SUPERUSER_ID + +def _create_subcontracting_rules(cr, registry): + """ This hook is used to add the default subcontracting rules on every warehouse/company. It is + necessary if the mrp_subcontracting module is installed after some warehouses + were already created. + """ + env = api.Environment(cr, SUPERUSER_ID, {}) + warehouse_ids = env['stock.warehouse'].search(['|', ('subcontracting_mto_pull_id', '=', False), ('subcontracting_pull_id', '=', False)]) + for warehouse_id in warehouse_ids: + warehouse_id.write({'subcontracting_to_resupply': warehouse_id.subcontracting_to_resupply}) + company_ids = env['res.company'].search([('subcontracting_location_id', '!=', False)]) + for company_id in company_ids: + wh = env['stock.warehouse'].search([('company_id', '=', company_id.id), ('active', '=', True)], limit=1) + production_location = wh._get_production_location() + rsoo_rule = env['stock.rule'].search([ + ('location_src_id', '=', company_id.subcontracting_location_id.id), + ('location_id', '=', production_location.id), + ('picking_type_id', '=', wh.manu_type_id.id) + ]) + if not rsoo_rule: + company_id._create_resupply_subcontractor_rules() |
