Skip to content

Commit

Permalink
[MIG] subcontracted_service: Migration to 12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
skukered committed Aug 22, 2019
1 parent f750fc5 commit ca9ce2b
Show file tree
Hide file tree
Showing 8 changed files with 563 additions and 38 deletions.
75 changes: 47 additions & 28 deletions subcontracted_service/README.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

======================
Subcontracted services
======================
=====================
Subcontracted service
=====================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/purchase-workflow/tree/12.0/subcontracted_service
:alt: OCA/purchase-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/purchase-workflow-12-0/purchase-workflow-12-0-subcontracted_service
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/142/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows a user to indicate that a service is subcontracted.
It provides the ability to create purchases from procurement processes.
Expand All @@ -20,6 +39,10 @@ Possible uses of this module can be:
* Add subcontracted services to sales order. When the SO is confirmed, it
creates a PO for the service.

**Table of contents**

.. contents::
:local:

Configuration
=============
Expand All @@ -35,49 +58,45 @@ To configure this module, you need to:
warehouse through 'Inventory / Configuration / Warehouse Management /
Warehouse'.

Usage
=====

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/142/11.0


Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/purchase-workflow/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20subcontracted_service%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Images
------
Authors
~~~~~~~

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.png>`_.
* Camptocamp

Contributors
------------
~~~~~~~~~~~~

* Damien Crier <[email protected]>
* Jordi Ballester Alomar <[email protected]>
* Lois Rilo <[email protected]>
* Rubén Bravo <[email protected]>

Maintainers
~~~~~~~~~~~

Maintainer
----------
This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://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 https://odoo-community.org.
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/12.0/subcontracted_service>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 3 additions & 2 deletions subcontracted_service/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# Author: Damien Crier
# Copyright 2017 Camptocamp SA
# Copyright 2019 Rubén Bravo <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": 'Subcontracted service',
"summary": 'Subcontracted service',
"version": "11.0.1.0.1",
"version": "12.0.1.0.0",
"category": "Purchase",
"website": "https://odoo-community.org/",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"purchase",
"purchase_stock",
],
"data": [
'views/product_template.xml',
Expand Down
16 changes: 9 additions & 7 deletions subcontracted_service/models/warehouse.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# Copyright 2019 Rubén Bravo <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models
Expand All @@ -9,18 +10,19 @@ class StockWarehouse(models.Model):
_inherit = 'stock.warehouse'

subcontracting_service_proc_rule_id = fields.Many2one(
comodel_name='procurement.rule',
comodel_name='stock.rule',
string="Subcontracting Service Procurement Rule"
)

def _get_buy_route(self):
return self.env.ref('purchase.route_warehouse0_buy',
return self.env.ref('purchase_stock.route_warehouse0_buy',
raise_if_not_found=False).id

@api.multi
def _get_vals_for_proc_rule_subcontracting(self):
self.ensure_one()
picking_type = self.in_type_id

if not picking_type:
picking_type = self.env['stock.picking.type'].search(
[('code', '=', 'incoming'),
Expand All @@ -36,16 +38,16 @@ def _get_vals_for_proc_rule_subcontracting(self):
'action': 'buy',
'picking_type_id': picking_type.id,
'route_id': self._get_buy_route(),
'location_id': picking_type.default_location_dest_id.id,
}

@api.multi
def _set_subcontracting_service_proc_rule(self):
for rec in self:
if rec.subcontracting_service_proc_rule_id:
continue
vals = rec._get_vals_for_proc_rule_subcontracting()
rule = self.env['procurement.rule'].create(vals)
rec.subcontracting_service_proc_rule_id = rule.id
if not rec.subcontracting_service_proc_rule_id:
vals = rec._get_vals_for_proc_rule_subcontracting()
rule = self.env['stock.rule'].create(vals)
rec.subcontracting_service_proc_rule_id = rule.id
return True

@api.model
Expand Down
10 changes: 10 additions & 0 deletions subcontracted_service/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
To configure this module, you need to:

#. Configure your service product with the flag
``property_subcontracted_service`` in product form if this product should
trigger a procurement.
#. Add supplier in your product form.
#. Additionally and despite a predefined rule is created in each warehouse,
you can configure the 'Subcontracting_service procurement rule' for each
warehouse through 'Inventory / Configuration / Warehouse Management /
Warehouse'.
4 changes: 4 additions & 0 deletions subcontracted_service/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Damien Crier <[email protected]>
* Jordi Ballester Alomar <[email protected]>
* Lois Rilo <[email protected]>
* Rubén Bravo <[email protected]>
13 changes: 13 additions & 0 deletions subcontracted_service/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This module allows a user to indicate that a service is subcontracted.
It provides the ability to create purchases from procurement processes.

This is a base module, upon specific modules for sale / manufacuturing, modules
will need to rely on. By itself it does not provide any function to the end user.

Possible uses of this module can be:

* Add subcontracted services to BOMs. When a manufacturing order is created a
PO is triggered for the service to be subcontracted. See

* Add subcontracted services to sales order. When the SO is confirmed, it
creates a PO for the service.
Loading

0 comments on commit ca9ce2b

Please sign in to comment.