mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
114
mrp_subcontracting_partner_management/README.rst
Normal file
114
mrp_subcontracting_partner_management/README.rst
Normal file
@@ -0,0 +1,114 @@
|
||||
=================================
|
||||
Subcontracting Partner Management
|
||||
=================================
|
||||
|
||||
..
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:7ade3317dda2abdd864cbca9382ef0508ebb9e2de4f245266c5584cd903b4200
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |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-LGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||
:alt: License: LGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/manufacture/tree/16.0/mrp_subcontracting_partner_management
|
||||
:alt: OCA/manufacture
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_subcontracting_partner_management
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
|
||||
:target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=16.0
|
||||
:alt: Try me on Runboat
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
The goal of this module is to simplify the management of the partner properties used in MRP Subcontracting.
|
||||
|
||||
It adds a new checkbox "Subcontractor" which when enabled creates the following entities:
|
||||
|
||||
* A child location in the "Subcontracting" location
|
||||
* A Stock Operation Type of type 'receipt' for this location
|
||||
* A new 'Buy' stock rule
|
||||
* A new 'Resupply Subcontractor on Order' rule
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
To see newly created rules, go to **Settings** > **Inventory** and activate "Multi step routes".
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
* Select a partner of type "Company"
|
||||
* Enable the "Subcontractor" checkbox
|
||||
* New entities are created or existing are used if were created previously
|
||||
* When disabled all associated enties will be archived
|
||||
* When name of subcontractor is updated, names of entities are updated automatically.
|
||||
* It is also possible to check inventory locations using **Subcontractor Location Stock** smart button on partner.
|
||||
|
||||
Changelog
|
||||
=========
|
||||
|
||||
14.0.1.0.1
|
||||
~~~~~~~~~~
|
||||
|
||||
**Bugfixes**
|
||||
- Fixed duplicate rules when creating a subcontractor partner
|
||||
|
||||
14.0.1.0.0
|
||||
~~~~~~~~~~
|
||||
|
||||
* Initial release
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_subcontracting_partner_management%0Aversion:%2016.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
|
||||
=======
|
||||
|
||||
Authors
|
||||
~~~~~~~
|
||||
|
||||
* Ooops404
|
||||
* Cetmix
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* Ooops404 <https://www.ooops404.com/>
|
||||
* Cetmix <https://cetmix.com/>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
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.
|
||||
|
||||
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/16.0/mrp_subcontracting_partner_management>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
1
mrp_subcontracting_partner_management/__init__.py
Normal file
1
mrp_subcontracting_partner_management/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
16
mrp_subcontracting_partner_management/__manifest__.py
Normal file
16
mrp_subcontracting_partner_management/__manifest__.py
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "Subcontracting Partner Management",
|
||||
"version": "16.0.1.0.0",
|
||||
"summary": "Subcontracting Partner Management",
|
||||
"author": "Ooops404, Cetmix, Odoo Community Association (OCA)",
|
||||
"license": "LGPL-3",
|
||||
"category": "Inventory",
|
||||
"website": "https://github.com/OCA/manufacture",
|
||||
"depends": ["purchase_stock", "mrp_subcontracting", "sale_stock"],
|
||||
"data": [
|
||||
"views/res_partner_views.xml",
|
||||
"views/stock_picking_type_views.xml",
|
||||
],
|
||||
"installable": True,
|
||||
"application": False,
|
||||
}
|
||||
86
mrp_subcontracting_partner_management/i18n/es.po
Normal file
86
mrp_subcontracting_partner_management/i18n/es.po
Normal file
@@ -0,0 +1,86 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * mrp_subcontracting_partner_management
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"PO-Revision-Date: 2023-12-28 00:50+0000\n"
|
||||
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: es\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 4.17\n"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model,name:mrp_subcontracting_partner_management.model_res_partner
|
||||
msgid "Contact"
|
||||
msgstr "Contacto"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__display_name
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_stock_picking_type__display_name
|
||||
msgid "Display Name"
|
||||
msgstr "Nombre mostrado"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_stock_picking_type__id
|
||||
msgid "ID"
|
||||
msgstr "ID"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_stock_picking_type__is_subcontractor
|
||||
msgid "Is Subcontractor"
|
||||
msgstr "Es subcontratista"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner____last_update
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_stock_picking_type____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr "Última modificación el"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__partner_buy_rule_id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__partner_buy_rule_id
|
||||
msgid "Partner Buy Rule"
|
||||
msgstr "Regla de compra de contacto"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__partner_picking_type_id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__partner_picking_type_id
|
||||
msgid "Partner Picking Type"
|
||||
msgstr "Tipo de operación de contacto"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__partner_resupply_rule_id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__partner_resupply_rule_id
|
||||
msgid "Partner Resupply Rule"
|
||||
msgstr "Regla de reabastecimiento de contacto"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model,name:mrp_subcontracting_partner_management.model_stock_picking_type
|
||||
msgid "Picking Type"
|
||||
msgstr "Tipo de operación"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__subcontracted_created_location_id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__subcontracted_created_location_id
|
||||
msgid "Subcontracted Created Location"
|
||||
msgstr "Ubicación de subcontratista creada"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__is_subcontractor_partner
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__is_subcontractor_partner
|
||||
#: model_terms:ir.ui.view,arch_db:mrp_subcontracting_partner_management.view_pickingtype_filter
|
||||
msgid "Subcontractor"
|
||||
msgstr "Subcontratista"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model_terms:ir.ui.view,arch_db:mrp_subcontracting_partner_management.view_partner_stock_form
|
||||
msgid "Subcontractor Location Stock"
|
||||
msgstr "Subcontratista Localización Existencias"
|
||||
86
mrp_subcontracting_partner_management/i18n/it.po
Normal file
86
mrp_subcontracting_partner_management/i18n/it.po
Normal file
@@ -0,0 +1,86 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * mrp_subcontracting_partner_management
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"PO-Revision-Date: 2023-07-17 17:16+0000\n"
|
||||
"Last-Translator: Francesco Foresti <francesco.foresti@ooops404.com>\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: it\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 4.17\n"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model,name:mrp_subcontracting_partner_management.model_res_partner
|
||||
msgid "Contact"
|
||||
msgstr "Contatto"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__display_name
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_stock_picking_type__display_name
|
||||
msgid "Display Name"
|
||||
msgstr "Nome visualizzato"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_stock_picking_type__id
|
||||
msgid "ID"
|
||||
msgstr "ID"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_stock_picking_type__is_subcontractor
|
||||
msgid "Is Subcontractor"
|
||||
msgstr "È un terzista"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner____last_update
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_stock_picking_type____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr "Ultima modifica il"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__partner_buy_rule_id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__partner_buy_rule_id
|
||||
msgid "Partner Buy Rule"
|
||||
msgstr "Regola di acquisto del partner"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__partner_picking_type_id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__partner_picking_type_id
|
||||
msgid "Partner Picking Type"
|
||||
msgstr "Tipo prelievo del partner"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__partner_resupply_rule_id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__partner_resupply_rule_id
|
||||
msgid "Partner Resupply Rule"
|
||||
msgstr "Regola rifornimento del partner"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model,name:mrp_subcontracting_partner_management.model_stock_picking_type
|
||||
msgid "Picking Type"
|
||||
msgstr "Tipologia prelievo"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__subcontracted_created_location_id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__subcontracted_created_location_id
|
||||
msgid "Subcontracted Created Location"
|
||||
msgstr "Ubicazione creata per terzista"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__is_subcontractor_partner
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__is_subcontractor_partner
|
||||
#: model_terms:ir.ui.view,arch_db:mrp_subcontracting_partner_management.view_pickingtype_filter
|
||||
msgid "Subcontractor"
|
||||
msgstr "Terzista"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model_terms:ir.ui.view,arch_db:mrp_subcontracting_partner_management.view_partner_stock_form
|
||||
msgid "Subcontractor Location Stock"
|
||||
msgstr "Magazzino ubicazione terzista"
|
||||
@@ -0,0 +1,83 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * mrp_subcontracting_partner_management
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model,name:mrp_subcontracting_partner_management.model_res_partner
|
||||
msgid "Contact"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__display_name
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_stock_picking_type__display_name
|
||||
msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_stock_picking_type__id
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_stock_picking_type__is_subcontractor
|
||||
msgid "Is Subcontractor"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner____last_update
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_stock_picking_type____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__partner_buy_rule_id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__partner_buy_rule_id
|
||||
msgid "Partner Buy Rule"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__partner_picking_type_id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__partner_picking_type_id
|
||||
msgid "Partner Picking Type"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__partner_resupply_rule_id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__partner_resupply_rule_id
|
||||
msgid "Partner Resupply Rule"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model,name:mrp_subcontracting_partner_management.model_stock_picking_type
|
||||
msgid "Picking Type"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__subcontracted_created_location_id
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__subcontracted_created_location_id
|
||||
msgid "Subcontracted Created Location"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__is_subcontractor_partner
|
||||
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_users__is_subcontractor_partner
|
||||
#: model_terms:ir.ui.view,arch_db:mrp_subcontracting_partner_management.view_pickingtype_filter
|
||||
msgid "Subcontractor"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_subcontracting_partner_management
|
||||
#: model_terms:ir.ui.view,arch_db:mrp_subcontracting_partner_management.view_partner_stock_form
|
||||
msgid "Subcontractor Location Stock"
|
||||
msgstr ""
|
||||
2
mrp_subcontracting_partner_management/models/__init__.py
Normal file
2
mrp_subcontracting_partner_management/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import res_partner
|
||||
from . import stock_picking_type
|
||||
227
mrp_subcontracting_partner_management/models/res_partner.py
Normal file
227
mrp_subcontracting_partner_management/models/res_partner.py
Normal file
@@ -0,0 +1,227 @@
|
||||
import re
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = "res.partner"
|
||||
|
||||
is_subcontractor_partner = fields.Boolean(string="Subcontractor")
|
||||
subcontracted_created_location_id = fields.Many2one(
|
||||
comodel_name="stock.location", copy=False
|
||||
)
|
||||
partner_picking_type_id = fields.Many2one(
|
||||
comodel_name="stock.picking.type", copy=False
|
||||
)
|
||||
partner_buy_rule_id = fields.Many2one(comodel_name="stock.rule", copy=False)
|
||||
partner_resupply_rule_id = fields.Many2one(comodel_name="stock.rule", copy=False)
|
||||
|
||||
def action_subcontractor_location_stock(self):
|
||||
"""Open subcontractor location stock list"""
|
||||
self.ensure_one()
|
||||
action = self.env["ir.actions.actions"]._for_xml_id(
|
||||
"stock.location_open_quants"
|
||||
)
|
||||
active_ids = self.property_stock_subcontractor.ids
|
||||
action.update(domain=[("location_id", "child_of", active_ids)])
|
||||
return action
|
||||
|
||||
@api.model
|
||||
def get_data_struct(self):
|
||||
return {
|
||||
# Updating Subcontracting Location
|
||||
"subcontracted_created_location_id": "_create_subcontracting_location_data",
|
||||
# Updating Subcontracting operation type
|
||||
"partner_picking_type_id": "_create_operation_type_for_subcontracting",
|
||||
# Updating Route Rule for Subcontracting buy
|
||||
"partner_buy_rule_id": "_create_route_rule_for_subcontracting",
|
||||
# Updating Route Rule for Subcontracting resupply
|
||||
"partner_resupply_rule_id": "_create_route_rule_for_subcontracting_resupply",
|
||||
}
|
||||
|
||||
def _set_subcontracting_values_active(self, active):
|
||||
"""Set subcontracting values active/inactive by argument key"""
|
||||
for key in self.get_data_struct():
|
||||
self.mapped(key).write({"active": active})
|
||||
|
||||
def _update_subcontractor_values_name(self, name):
|
||||
"""
|
||||
Update subcontractor related records:
|
||||
- Location;
|
||||
- Operation type;
|
||||
- Route Rule for Subcontracting buy;
|
||||
- Route Rule for Subcontracting resupply.
|
||||
"""
|
||||
partners = self.filtered(lambda p: p.is_subcontractor_partner)
|
||||
field_names = [*self.get_data_struct(), "property_stock_subcontractor"]
|
||||
field_names.remove("partner_picking_type_id")
|
||||
for field in field_names:
|
||||
records = partners.mapped(field)
|
||||
records.write({"name": name})
|
||||
type_name = "%s: IN" % name
|
||||
code = "".join(re.findall(r"\b\w", type_name))
|
||||
picks = partners.mapped("partner_picking_type_id")
|
||||
picks.write({"name": type_name, "sequence_code": code})
|
||||
|
||||
def unlink(self):
|
||||
"""This Method is override to archive all subcontracting field"""
|
||||
self._set_subcontracting_values_active(False)
|
||||
return super().unlink()
|
||||
|
||||
def write(self, vals):
|
||||
if "is_subcontractor_partner" in vals:
|
||||
self._update_subcontractor_entities_for_record(
|
||||
vals.get("is_subcontractor_partner")
|
||||
)
|
||||
if "active" in vals:
|
||||
self._set_subcontracting_values_active(vals.get("active"))
|
||||
result = super().write(vals)
|
||||
if vals.get("name"):
|
||||
self._update_subcontractor_values_name(vals.get("name"))
|
||||
return result
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
check_data = self.get_data_struct().items()
|
||||
for vals in filter(
|
||||
lambda v: v.get("is_subcontractor_partner") and v.get("is_company"),
|
||||
vals_list,
|
||||
):
|
||||
for key, func in check_data:
|
||||
if not getattr(self, key) or not vals.get(key):
|
||||
vals.update(
|
||||
**getattr(
|
||||
self.with_context(partner_name=vals.get("name")), func
|
||||
)(vals)
|
||||
or {}
|
||||
)
|
||||
return super().create(vals_list)
|
||||
|
||||
def _update_subcontractor_entities_for_record(self, is_subcontractor_partner):
|
||||
if not is_subcontractor_partner:
|
||||
return self._set_subcontracting_values_active(False)
|
||||
data_items = self.get_data_struct().items()
|
||||
for rec in self:
|
||||
vals = {}
|
||||
for key, record, func in map(
|
||||
lambda f: (f[0], getattr(rec, f[0]), f[1]), data_items
|
||||
):
|
||||
if record:
|
||||
record.active = True
|
||||
else:
|
||||
if not getattr(rec, key) or not vals.get(key):
|
||||
vals.update(**getattr(rec, func)(vals) or {})
|
||||
if vals:
|
||||
rec.write(vals)
|
||||
|
||||
def _compose_entity_name(self):
|
||||
"""
|
||||
Compose entity name. Override this function to implement onw logic
|
||||
:return: name (char) composed name
|
||||
"""
|
||||
return self.display_name
|
||||
|
||||
def _create_subcontracted_operation_type(self, vals):
|
||||
"""Creating Operation Type for Subcontracting"""
|
||||
location_id = self._get_location_id_for_record(vals)
|
||||
if "partner_picking_type_id" in vals:
|
||||
return vals.get("partner_picking_type_id"), location_id
|
||||
if self.partner_picking_type_id:
|
||||
return self.partner_picking_type_id.id, location_id
|
||||
operation_type_name = "%s: IN" % self._context.get(
|
||||
"partner_name", self._compose_entity_name()
|
||||
)
|
||||
operation_type_vals = {
|
||||
"name": operation_type_name,
|
||||
"code": "incoming",
|
||||
"sequence_code": "".join(re.findall(r"\b\w", operation_type_name)),
|
||||
"is_subcontractor": True,
|
||||
}
|
||||
company = self.company_id or self.env.company
|
||||
warehouse = self.env["stock.warehouse"].search(
|
||||
[("company_id", "=", company.id)], limit=1
|
||||
)
|
||||
if warehouse:
|
||||
operation_type_vals.update({"warehouse_id": warehouse.id})
|
||||
if location_id:
|
||||
operation_type_vals.update({"default_location_dest_id": location_id})
|
||||
return (
|
||||
self.env["stock.picking.type"].create(operation_type_vals).id,
|
||||
location_id,
|
||||
)
|
||||
|
||||
def _get_location_id_for_record(self, vals):
|
||||
if "subcontracted_created_location_id" in vals:
|
||||
return vals.get("subcontracted_created_location_id")
|
||||
if self.subcontracted_created_location_id:
|
||||
return self.subcontracted_created_location_id.id
|
||||
company = self.company_id or self.env.company
|
||||
parent_location = (
|
||||
company.subcontracting_location_id and company.subcontracting_location_id.id
|
||||
)
|
||||
return (
|
||||
self.env["stock.location"]
|
||||
.create(
|
||||
{
|
||||
"name": self._context.get(
|
||||
"partner_name", self._compose_entity_name()
|
||||
),
|
||||
"usage": "internal",
|
||||
"location_id": parent_location or False,
|
||||
"company_id": company.id,
|
||||
"active": True,
|
||||
}
|
||||
)
|
||||
.id
|
||||
)
|
||||
|
||||
def _create_subcontracting_location_data(self, vals):
|
||||
location_id = self._get_location_id_for_record(vals)
|
||||
return {
|
||||
"property_stock_subcontractor": location_id,
|
||||
"subcontracted_created_location_id": location_id,
|
||||
}
|
||||
|
||||
def _create_operation_type_for_subcontracting(self, vals):
|
||||
# Creating Operation Type for Subcontracting starts here
|
||||
picking_type_id, _ = self._create_subcontracted_operation_type(vals)
|
||||
return {"partner_picking_type_id": picking_type_id}
|
||||
|
||||
def _create_route_rule_for_subcontracting(self, vals):
|
||||
picking_type_id, location_id = self._create_subcontracted_operation_type(vals)
|
||||
route = self.env.ref(
|
||||
"purchase_stock.route_warehouse0_buy", raise_if_not_found=False
|
||||
)
|
||||
buy_rule = self.env["stock.rule"].create(
|
||||
{
|
||||
"name": self._context.get("partner_name", self._compose_entity_name()),
|
||||
"action": "buy",
|
||||
"picking_type_id": picking_type_id,
|
||||
"location_dest_id": location_id,
|
||||
"route_id": route.id,
|
||||
}
|
||||
)
|
||||
return {"partner_buy_rule_id": buy_rule.id}
|
||||
|
||||
def _create_route_rule_for_subcontracting_resupply(self, vals):
|
||||
prop = self.env["ir.property"]._get(
|
||||
"property_stock_production", "product.template"
|
||||
)
|
||||
picking_type = self.env.ref("stock.picking_type_out", raise_if_not_found=False)
|
||||
route = self.env.ref(
|
||||
"mrp_subcontracting.route_resupply_subcontractor_mto",
|
||||
raise_if_not_found=False,
|
||||
)
|
||||
rule = self.env["stock.rule"].create(
|
||||
{
|
||||
"name": self._context.get("partner_name", self._compose_entity_name()),
|
||||
"action": "pull",
|
||||
"partner_address_id": self._origin.id,
|
||||
"picking_type_id": picking_type.id,
|
||||
"location_dest_id": prop.id,
|
||||
"location_src_id": self._get_location_id_for_record(vals),
|
||||
"route_id": route.id,
|
||||
"procure_method": "mts_else_mto",
|
||||
}
|
||||
)
|
||||
return {"partner_resupply_rule_id": rule.id}
|
||||
@@ -0,0 +1,7 @@
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class StockPickingType(models.Model):
|
||||
_inherit = "stock.picking.type"
|
||||
|
||||
is_subcontractor = fields.Boolean()
|
||||
@@ -0,0 +1 @@
|
||||
To see newly created rules, go to **Settings** > **Inventory** and activate "Multi step routes".
|
||||
@@ -0,0 +1,2 @@
|
||||
* Ooops404 <https://www.ooops404.com/>
|
||||
* Cetmix <https://cetmix.com/>
|
||||
@@ -0,0 +1,8 @@
|
||||
The goal of this module is to simplify the management of the partner properties used in MRP Subcontracting.
|
||||
|
||||
It adds a new checkbox "Subcontractor" which when enabled creates the following entities:
|
||||
|
||||
* A child location in the "Subcontracting" location
|
||||
* A Stock Operation Type of type 'receipt' for this location
|
||||
* A new 'Buy' stock rule
|
||||
* A new 'Resupply Subcontractor on Order' rule
|
||||
10
mrp_subcontracting_partner_management/readme/HISTORY.rst
Normal file
10
mrp_subcontracting_partner_management/readme/HISTORY.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
14.0.1.0.1
|
||||
~~~~~~~~~~
|
||||
|
||||
**Bugfixes**
|
||||
- Fixed duplicate rules when creating a subcontractor partner
|
||||
|
||||
14.0.1.0.0
|
||||
~~~~~~~~~~
|
||||
|
||||
* Initial release
|
||||
6
mrp_subcontracting_partner_management/readme/USAGE.rst
Normal file
6
mrp_subcontracting_partner_management/readme/USAGE.rst
Normal file
@@ -0,0 +1,6 @@
|
||||
* Select a partner of type "Company"
|
||||
* Enable the "Subcontractor" checkbox
|
||||
* New entities are created or existing are used if were created previously
|
||||
* When disabled all associated enties will be archived
|
||||
* When name of subcontractor is updated, names of entities are updated automatically.
|
||||
* It is also possible to check inventory locations using **Subcontractor Location Stock** smart button on partner.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
@@ -0,0 +1,466 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
|
||||
<title>Subcontracting Partner Management</title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
:Author: David Goodger (goodger@python.org)
|
||||
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
|
||||
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
|
||||
customize this style sheet.
|
||||
*/
|
||||
|
||||
/* used to remove borders from tables and images */
|
||||
.borderless, table.borderless td, table.borderless th {
|
||||
border: 0 }
|
||||
|
||||
table.borderless td, table.borderless th {
|
||||
/* Override padding for "table.docutils td" with "! important".
|
||||
The right padding separates the table cells. */
|
||||
padding: 0 0.5em 0 0 ! important }
|
||||
|
||||
.first {
|
||||
/* Override more specific margin styles with "! important". */
|
||||
margin-top: 0 ! important }
|
||||
|
||||
.last, .with-subtitle {
|
||||
margin-bottom: 0 ! important }
|
||||
|
||||
.hidden {
|
||||
display: none }
|
||||
|
||||
.subscript {
|
||||
vertical-align: sub;
|
||||
font-size: smaller }
|
||||
|
||||
.superscript {
|
||||
vertical-align: super;
|
||||
font-size: smaller }
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none ;
|
||||
color: black }
|
||||
|
||||
blockquote.epigraph {
|
||||
margin: 2em 5em ; }
|
||||
|
||||
dl.docutils dd {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
||||
dl.docutils dt {
|
||||
font-weight: bold }
|
||||
*/
|
||||
|
||||
div.abstract {
|
||||
margin: 2em 5em }
|
||||
|
||||
div.abstract p.topic-title {
|
||||
font-weight: bold ;
|
||||
text-align: center }
|
||||
|
||||
div.admonition, div.attention, div.caution, div.danger, div.error,
|
||||
div.hint, div.important, div.note, div.tip, div.warning {
|
||||
margin: 2em ;
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||
div.important p.admonition-title, div.note p.admonition-title,
|
||||
div.tip p.admonition-title {
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title, .code .error {
|
||||
color: red ;
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
/* Uncomment (and remove this text!) to get reduced vertical space in
|
||||
compound paragraphs.
|
||||
div.compound .compound-first, div.compound .compound-middle {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
div.compound .compound-last, div.compound .compound-middle {
|
||||
margin-top: 0.5em }
|
||||
*/
|
||||
|
||||
div.dedication {
|
||||
margin: 2em 5em ;
|
||||
text-align: center ;
|
||||
font-style: italic }
|
||||
|
||||
div.dedication p.topic-title {
|
||||
font-weight: bold ;
|
||||
font-style: normal }
|
||||
|
||||
div.figure {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
div.footer, div.header {
|
||||
clear: both;
|
||||
font-size: smaller }
|
||||
|
||||
div.line-block {
|
||||
display: block ;
|
||||
margin-top: 1em ;
|
||||
margin-bottom: 1em }
|
||||
|
||||
div.line-block div.line-block {
|
||||
margin-top: 0 ;
|
||||
margin-bottom: 0 ;
|
||||
margin-left: 1.5em }
|
||||
|
||||
div.sidebar {
|
||||
margin: 0 0 0.5em 1em ;
|
||||
border: medium outset ;
|
||||
padding: 1em ;
|
||||
background-color: #ffffee ;
|
||||
width: 40% ;
|
||||
float: right ;
|
||||
clear: right }
|
||||
|
||||
div.sidebar p.rubric {
|
||||
font-family: sans-serif ;
|
||||
font-size: medium }
|
||||
|
||||
div.system-messages {
|
||||
margin: 5em }
|
||||
|
||||
div.system-messages h1 {
|
||||
color: red }
|
||||
|
||||
div.system-message {
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.system-message p.system-message-title {
|
||||
color: red ;
|
||||
font-weight: bold }
|
||||
|
||||
div.topic {
|
||||
margin: 2em }
|
||||
|
||||
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
||||
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
||||
margin-top: 0.4em }
|
||||
|
||||
h1.title {
|
||||
text-align: center }
|
||||
|
||||
h2.subtitle {
|
||||
text-align: center }
|
||||
|
||||
hr.docutils {
|
||||
width: 75% }
|
||||
|
||||
img.align-left, .figure.align-left, object.align-left, table.align-left {
|
||||
clear: left ;
|
||||
float: left ;
|
||||
margin-right: 1em }
|
||||
|
||||
img.align-right, .figure.align-right, object.align-right, table.align-right {
|
||||
clear: right ;
|
||||
float: right ;
|
||||
margin-left: 1em }
|
||||
|
||||
img.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left }
|
||||
|
||||
.align-center {
|
||||
clear: both ;
|
||||
text-align: center }
|
||||
|
||||
.align-right {
|
||||
text-align: right }
|
||||
|
||||
/* reset inner alignment in figures */
|
||||
div.align-right {
|
||||
text-align: inherit }
|
||||
|
||||
/* div.align-center * { */
|
||||
/* text-align: left } */
|
||||
|
||||
.align-top {
|
||||
vertical-align: top }
|
||||
|
||||
.align-middle {
|
||||
vertical-align: middle }
|
||||
|
||||
.align-bottom {
|
||||
vertical-align: bottom }
|
||||
|
||||
ol.simple, ul.simple {
|
||||
margin-bottom: 1em }
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal }
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha }
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha }
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman }
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman }
|
||||
|
||||
p.attribution {
|
||||
text-align: right ;
|
||||
margin-left: 50% }
|
||||
|
||||
p.caption {
|
||||
font-style: italic }
|
||||
|
||||
p.credits {
|
||||
font-style: italic ;
|
||||
font-size: smaller }
|
||||
|
||||
p.label {
|
||||
white-space: nowrap }
|
||||
|
||||
p.rubric {
|
||||
font-weight: bold ;
|
||||
font-size: larger ;
|
||||
color: maroon ;
|
||||
text-align: center }
|
||||
|
||||
p.sidebar-title {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold ;
|
||||
font-size: larger }
|
||||
|
||||
p.sidebar-subtitle {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
p.topic-title {
|
||||
font-weight: bold }
|
||||
|
||||
pre.address {
|
||||
margin-bottom: 0 ;
|
||||
margin-top: 0 ;
|
||||
font: inherit }
|
||||
|
||||
pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
pre.code .ln { color: grey; } /* line numbers */
|
||||
pre.code, code { background-color: #eeeeee }
|
||||
pre.code .comment, code .comment { color: #5C6576 }
|
||||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||
pre.code .literal.string, code .literal.string { color: #0C5404 }
|
||||
pre.code .name.builtin, code .name.builtin { color: #352B84 }
|
||||
pre.code .deleted, code .deleted { background-color: #DEB0A1}
|
||||
pre.code .inserted, code .inserted { background-color: #A3D289}
|
||||
|
||||
span.classifier {
|
||||
font-family: sans-serif ;
|
||||
font-style: oblique }
|
||||
|
||||
span.classifier-delimiter {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
span.interpreted {
|
||||
font-family: sans-serif }
|
||||
|
||||
span.option {
|
||||
white-space: nowrap }
|
||||
|
||||
span.pre {
|
||||
white-space: pre }
|
||||
|
||||
span.problematic {
|
||||
color: red }
|
||||
|
||||
span.section-subtitle {
|
||||
/* font-size relative to parent (h1..h6 element) */
|
||||
font-size: 80% }
|
||||
|
||||
table.citation {
|
||||
border-left: solid 1px gray;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docinfo {
|
||||
margin: 2em 4em }
|
||||
|
||||
table.docutils {
|
||||
margin-top: 0.5em ;
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
table.footnote {
|
||||
border-left: solid 1px black;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docutils td, table.docutils th,
|
||||
table.docinfo td, table.docinfo th {
|
||||
padding-left: 0.5em ;
|
||||
padding-right: 0.5em ;
|
||||
vertical-align: top }
|
||||
|
||||
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
||||
font-weight: bold ;
|
||||
text-align: left ;
|
||||
white-space: nowrap ;
|
||||
padding-left: 0 }
|
||||
|
||||
/* "booktabs" style (no vertical lines) */
|
||||
table.docutils.booktabs {
|
||||
border: 0px;
|
||||
border-top: 2px solid;
|
||||
border-bottom: 2px solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.docutils.booktabs * {
|
||||
border: 0px;
|
||||
}
|
||||
table.docutils.booktabs th {
|
||||
border-bottom: thin solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
||||
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
||||
font-size: 100% }
|
||||
|
||||
ul.auto-toc {
|
||||
list-style-type: none }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="subcontracting-partner-management">
|
||||
<h1 class="title">Subcontracting Partner Management</h1>
|
||||
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:7ade3317dda2abdd864cbca9382ef0508ebb9e2de4f245266c5584cd903b4200
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/manufacture/tree/16.0/mrp_subcontracting_partner_management"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_subcontracting_partner_management"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p>The goal of this module is to simplify the management of the partner properties used in MRP Subcontracting.</p>
|
||||
<p>It adds a new checkbox “Subcontractor” which when enabled creates the following entities:</p>
|
||||
<ul class="simple">
|
||||
<li>A child location in the “Subcontracting” location</li>
|
||||
<li>A Stock Operation Type of type ‘receipt’ for this location</li>
|
||||
<li>A new ‘Buy’ stock rule</li>
|
||||
<li>A new ‘Resupply Subcontractor on Order’ rule</li>
|
||||
</ul>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
|
||||
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
|
||||
<li><a class="reference internal" href="#changelog" id="toc-entry-3">Changelog</a><ul>
|
||||
<li><a class="reference internal" href="#section-1" id="toc-entry-4">14.0.1.0.1</a></li>
|
||||
<li><a class="reference internal" href="#section-2" id="toc-entry-5">14.0.1.0.0</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-6">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="toc-entry-7">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="toc-entry-8">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="toc-entry-9">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="toc-entry-10">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="configuration">
|
||||
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
|
||||
<p>To see newly created rules, go to <strong>Settings</strong> > <strong>Inventory</strong> and activate “Multi step routes”.</p>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
|
||||
<ul class="simple">
|
||||
<li>Select a partner of type “Company”</li>
|
||||
<li>Enable the “Subcontractor” checkbox</li>
|
||||
<li>New entities are created or existing are used if were created previously</li>
|
||||
<li>When disabled all associated enties will be archived</li>
|
||||
<li>When name of subcontractor is updated, names of entities are updated automatically.</li>
|
||||
<li>It is also possible to check inventory locations using <strong>Subcontractor Location Stock</strong> smart button on partner.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="changelog">
|
||||
<h1><a class="toc-backref" href="#toc-entry-3">Changelog</a></h1>
|
||||
<div class="section" id="section-1">
|
||||
<h2><a class="toc-backref" href="#toc-entry-4">14.0.1.0.1</a></h2>
|
||||
<p><strong>Bugfixes</strong>
|
||||
- Fixed duplicate rules when creating a subcontractor partner</p>
|
||||
</div>
|
||||
<div class="section" id="section-2">
|
||||
<h2><a class="toc-backref" href="#toc-entry-5">14.0.1.0.0</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Initial release</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h1><a class="toc-backref" href="#toc-entry-6">Bug Tracker</a></h1>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/manufacture/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_subcontracting_partner_management%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
<h1><a class="toc-backref" href="#toc-entry-7">Credits</a></h1>
|
||||
<div class="section" id="authors">
|
||||
<h2><a class="toc-backref" href="#toc-entry-8">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Ooops404</li>
|
||||
<li>Cetmix</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#toc-entry-9">Contributors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Ooops404 <<a class="reference external" href="https://www.ooops404.com/">https://www.ooops404.com/</a>></li>
|
||||
<li>Cetmix <<a class="reference external" href="https://cetmix.com/">https://cetmix.com/</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#toc-entry-10">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||
<p>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.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/16.0/mrp_subcontracting_partner_management">OCA/manufacture</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
3
mrp_subcontracting_partner_management/tests/__init__.py
Normal file
3
mrp_subcontracting_partner_management/tests/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import test_create_subcontractor_partner_location
|
||||
@@ -0,0 +1,202 @@
|
||||
from odoo.tests import tagged
|
||||
|
||||
from odoo.addons.base.tests.common import BaseCommon
|
||||
|
||||
|
||||
@tagged("post_install", "-at_install")
|
||||
class TestSubcontractedPartner(BaseCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.partner_obj = cls.env["res.partner"]
|
||||
cls.partner = cls.partner_obj.create({"name": "Test partner"})
|
||||
|
||||
def test_is_subcontractor_partner_first_time(self):
|
||||
self.partner.update({"is_subcontractor_partner": True})
|
||||
location = self.partner.subcontracted_created_location_id
|
||||
self.assertTrue(location, "Location is not created")
|
||||
self.assertTrue(location.active, "Location must be active")
|
||||
|
||||
partner_picking_type = self.partner.partner_picking_type_id
|
||||
self.assertTrue(partner_picking_type, "Picking type is not created")
|
||||
self.assertTrue(partner_picking_type.active, "Picking type must be active")
|
||||
|
||||
partner_buy_rule = self.partner.partner_buy_rule_id
|
||||
self.assertTrue(partner_buy_rule, "Partner Buy rule is not created")
|
||||
self.assertTrue(partner_buy_rule.active, "Partner Buy rule must be active")
|
||||
|
||||
partner_resupply_rule = self.partner.partner_resupply_rule_id
|
||||
self.assertTrue(partner_resupply_rule, "Partner Resupply rule is not created")
|
||||
self.assertTrue(
|
||||
partner_resupply_rule.active, "Partner Resupply rule must be active"
|
||||
)
|
||||
|
||||
def test_is_subcontractor_partner_switch_off(self):
|
||||
self.partner.write({"is_subcontractor_partner": True})
|
||||
self.partner.update({"is_subcontractor_partner": False})
|
||||
|
||||
location = self.partner.subcontracted_created_location_id
|
||||
self.assertFalse(location.active, "Location must be not active")
|
||||
|
||||
partner_picking_type = self.partner.partner_picking_type_id
|
||||
self.assertFalse(partner_picking_type.active, "Picking type must be not active")
|
||||
|
||||
partner_buy_rule = self.partner.partner_buy_rule_id
|
||||
self.assertFalse(partner_buy_rule.active, "Partner Buy rule must be not active")
|
||||
|
||||
partner_resupply_rule = self.partner.partner_resupply_rule_id
|
||||
self.assertFalse(
|
||||
partner_resupply_rule.active, "Partner Resupply rule must be not active"
|
||||
)
|
||||
|
||||
def test_is_subcontractor_partner_switch_on(self):
|
||||
self.partner.update({"is_subcontractor_partner": True})
|
||||
|
||||
location = self.partner.subcontracted_created_location_id
|
||||
self.assertTrue(location.active, "Location must be active")
|
||||
|
||||
partner_picking_type = self.partner.partner_picking_type_id
|
||||
self.assertTrue(partner_picking_type.active, "Picking type must be active")
|
||||
|
||||
partner_buy_rule = self.partner.partner_buy_rule_id
|
||||
self.assertTrue(partner_buy_rule.active, "Partner Buy rule must be active")
|
||||
|
||||
partner_resupply_rule = self.partner.partner_resupply_rule_id
|
||||
self.assertTrue(
|
||||
partner_resupply_rule.active, "Partner Resupply rule must be active"
|
||||
)
|
||||
|
||||
def test_is_subcontractor_partner_active_switch_off(self):
|
||||
self.partner.write({"is_subcontractor_partner": True})
|
||||
self.partner.update({"active": False})
|
||||
|
||||
location = self.partner.subcontracted_created_location_id
|
||||
self.assertFalse(location.active, "Location must be not active")
|
||||
|
||||
partner_picking_type = self.partner.partner_picking_type_id
|
||||
self.assertFalse(partner_picking_type.active, "Picking type must be not active")
|
||||
|
||||
partner_buy_rule = self.partner.partner_buy_rule_id
|
||||
self.assertFalse(partner_buy_rule.active, "Partner Buy rule must be not active")
|
||||
|
||||
partner_resupply_rule = self.partner.partner_resupply_rule_id
|
||||
self.assertFalse(
|
||||
partner_resupply_rule.active, "Partner Resupply rule must be not active"
|
||||
)
|
||||
|
||||
def test_is_subcontractor_partner_aсtive_switch_on(self):
|
||||
self.partner.write({"is_subcontractor_partner": True})
|
||||
self.partner.write({"active": True})
|
||||
|
||||
location = self.partner.subcontracted_created_location_id
|
||||
self.assertTrue(location.active, "Location must be active")
|
||||
|
||||
partner_picking_type = self.partner.partner_picking_type_id
|
||||
self.assertTrue(partner_picking_type.active, "Picking type must be active")
|
||||
|
||||
partner_buy_rule = self.partner.partner_buy_rule_id
|
||||
self.assertTrue(partner_buy_rule.active, "Partner Buy rule must be active")
|
||||
|
||||
partner_resupply_rule = self.partner.partner_resupply_rule_id
|
||||
self.assertTrue(
|
||||
partner_resupply_rule.active, "Partner Resupply rule must be active"
|
||||
)
|
||||
|
||||
def test_is_subcontractor_partner_delete(self):
|
||||
partner = self.partner_obj.create(
|
||||
{
|
||||
"name": "Test partner",
|
||||
"is_company": True,
|
||||
"is_subcontractor_partner": True,
|
||||
}
|
||||
)
|
||||
|
||||
location = partner.subcontracted_created_location_id
|
||||
partner_picking_type = partner.partner_picking_type_id
|
||||
partner_buy_rule = partner.partner_buy_rule_id
|
||||
partner_resupply_rule = partner.partner_resupply_rule_id
|
||||
|
||||
partner.unlink()
|
||||
|
||||
self.assertFalse(location.active, "Location must be not active")
|
||||
self.assertFalse(partner_picking_type.active, "Picking type must be not active")
|
||||
self.assertFalse(partner_buy_rule.active, "Partner Buy rule must be not active")
|
||||
self.assertFalse(
|
||||
partner_resupply_rule.active, "Partner Resupply rule must be not active"
|
||||
)
|
||||
|
||||
def test_check_countof_rules(self):
|
||||
partner = self.partner_obj.create(
|
||||
{
|
||||
"name": "Test partner",
|
||||
"is_company": True,
|
||||
"is_subcontractor_partner": True,
|
||||
}
|
||||
)
|
||||
rules = self.env["stock.rule"].search(
|
||||
[("name", "=", partner.partner_buy_rule_id.name)]
|
||||
)
|
||||
self.assertTrue(len(rules) == 2, "There are must be 2 subcontractor rules")
|
||||
|
||||
def test_change_subcontractor_location(self):
|
||||
expected_text = "Test partner"
|
||||
partner = self.partner_obj.create(
|
||||
{
|
||||
"name": "Test partner",
|
||||
"is_company": True,
|
||||
"is_subcontractor_partner": True,
|
||||
}
|
||||
)
|
||||
location = partner.property_stock_subcontractor
|
||||
self.assertEqual(
|
||||
location.name,
|
||||
expected_text,
|
||||
msg="Location name must be equal to {}".format(expected_text),
|
||||
)
|
||||
|
||||
fields = [
|
||||
"subcontracted_created_location_id",
|
||||
"partner_buy_rule_id",
|
||||
"partner_resupply_rule_id",
|
||||
"property_stock_subcontractor",
|
||||
]
|
||||
expected_text = "Test partner 1"
|
||||
partner.name = expected_text
|
||||
for field in fields:
|
||||
location = getattr(partner, field)
|
||||
self.assertEqual(
|
||||
location.name,
|
||||
expected_text,
|
||||
msg="Record name must be equal to {}".format(expected_text),
|
||||
)
|
||||
|
||||
picking = partner.partner_picking_type_id
|
||||
expected_text = "%s: IN" % expected_text
|
||||
self.assertEqual(
|
||||
picking.name,
|
||||
expected_text,
|
||||
msg="Record name must be equal to '{}'".format(expected_text),
|
||||
)
|
||||
self.assertEqual(
|
||||
picking.sequence_code, "Tp1I", msg="Sequence code must be equal to 'Tp1I'"
|
||||
)
|
||||
|
||||
def test_action_subcontractor_location_stock(self):
|
||||
self.partner.update({"is_subcontractor_partner": True})
|
||||
action = self.partner.action_subcontractor_location_stock()
|
||||
self.assertEqual(
|
||||
action.get("domain"),
|
||||
[
|
||||
(
|
||||
"location_id",
|
||||
"child_of",
|
||||
self.partner.property_stock_subcontractor.ids,
|
||||
)
|
||||
],
|
||||
msg="Domains must be the same",
|
||||
)
|
||||
self.assertEqual(
|
||||
action.get("res_model"),
|
||||
"stock.quant",
|
||||
msg="Model must be equal to 'stock.quant'",
|
||||
)
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<!-- Add fields to partner form -->
|
||||
<record id="view_partner_form_inherit_subcontractor" model="ir.ui.view">
|
||||
<field name="name">res.partner.form.inherit.subcontractor</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="account.view_partner_property_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="property_supplier_payment_term_id" position="before">
|
||||
<field
|
||||
name="is_subcontractor_partner"
|
||||
attrs="{'invisible': [('is_company', '=', False)]}"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_partner_stock_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.stock.property.form.inherit</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="stock.view_partner_stock_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@name='button_box']" position="inside">
|
||||
<field name="is_subcontractor_partner" invisible="1" />
|
||||
<button
|
||||
string="Subcontractor Location Stock"
|
||||
name="action_subcontractor_location_stock"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
attrs="{'invisible': [('is_subcontractor_partner', '!=', True)]}"
|
||||
icon="fa-cubes"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<!-- Add filter for subcontracting operation types -->
|
||||
<record id="view_pickingtype_filter" model="ir.ui.view">
|
||||
<field name="name">stock.picking.type.filter.subcontractor</field>
|
||||
<field name="model">stock.picking.type</field>
|
||||
<field name="inherit_id" ref="stock.view_pickingtype_filter" />
|
||||
<field name="arch" type="xml">
|
||||
<filter name="inactive" position="after">
|
||||
<filter
|
||||
string="Subcontractor"
|
||||
name="subocont"
|
||||
domain="[('is_subcontractor','=',True)]"
|
||||
/>
|
||||
</filter>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -0,0 +1 @@
|
||||
../../../../mrp_subcontracting_partner_management
|
||||
6
setup/mrp_subcontracting_partner_management/setup.py
Normal file
6
setup/mrp_subcontracting_partner_management/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
Reference in New Issue
Block a user