[14.0][ADD] Subcontractor Partner Management

[UPD] Update mrp_subcontracting_partner_management.pot

[UPD] README.rst
This commit is contained in:
i1
2022-05-06 13:19:06 +02:00
committed by Víctor Martínez
parent 2157188cc4
commit 39a8e09d46
16 changed files with 1125 additions and 0 deletions

View File

@@ -0,0 +1,103 @@
=================================
Subcontracting Partner Management
=================================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-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/14.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-14-0/manufacture-14-0-mrp_subcontracting_partner_management
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/129/14.0
:alt: Try me on Runbot
|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
=============
* No configuration is required
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
Changelog
=========
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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_subcontracting_partner_management%0Aversion:%2014.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/14.0/mrp_subcontracting_partner_management>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -0,0 +1,18 @@
{
"name": "Subcontracting Partner Management",
"version": "14.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"],
"external_dependencies": {},
"demo": [],
"data": [
"views/res_partner.xml",
],
"qweb": [],
"installable": True,
"application": False,
}

View File

@@ -0,0 +1,65 @@
# 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
msgid "Display Name"
msgstr ""
#. module: mrp_subcontracting_partner_management
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner__id
msgid "ID"
msgstr ""
#. module: mrp_subcontracting_partner_management
#: model:ir.model.fields,field_description:mrp_subcontracting_partner_management.field_res_partner____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.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_partner_form_inherit_subcontractor
msgid "Subcontractor"
msgstr ""

View File

@@ -0,0 +1 @@
from . import res_partner

View File

@@ -0,0 +1,267 @@
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("stock.location")
partner_picking_type_id = fields.Many2one("stock.picking.type")
partner_buy_rule_id = fields.Many2one("stock.rule")
partner_resupply_rule_id = fields.Many2one("stock.rule")
def _set_subcontracting_values_active(self, active):
self.ensure_one()
if self.subcontracted_created_location_id:
self.subcontracted_created_location_id.active = active
if self.partner_picking_type_id:
self.partner_picking_type_id.active = active
if self.partner_buy_rule_id:
self.partner_buy_rule_id.active = active
if self.partner_resupply_rule_id:
self.partner_resupply_rule_id.active = active
def unlink(self):
"""
This Method is override to archive all subcotracting field
"""
for record in self:
record._set_subcontracting_values_active(False)
result = super(ResPartner, self).unlink()
return result
def write(self, values):
for record in self:
is_subcontractor_partner = values.get("is_subcontractor_partner")
active = values.get("active")
if is_subcontractor_partner is not None:
values.update(record._update_subcontractor_entities_for_record(values))
if active is not None:
record._set_subcontracting_values_active(active)
super(ResPartner, self).write(values)
@api.model
def create(self, values):
partner = super(ResPartner, self).create(values)
if values.get("is_subcontractor_partner", False):
partner._create_subcontractor_entities()
return partner
def _create_location(self, parent_location, company):
"""Creating Subcontracting Location starts here"""
name = "Subcontractor {}".format(self.name)
location_vals = {
"name": name,
"usage": "internal",
"location_id": parent_location or False,
"company_id": company.id,
"active": True,
}
location_rec = self.subcontracted_created_location_id
if not location_rec:
location_rec = self.env["stock.location"].create(location_vals)
return location_rec
def _create_subcontracted_operation_type(self, warehouse, location):
"""Creating Operation Type for Subcontracting"""
first_name = self.name.split(" ")[0] or ""
operation_type_name = "Subcontractor {} {}".format(str(first_name), " IN")
sequence_code = ""
for code in list(filter(None, operation_type_name.split(" "))):
sequence_code += code[0]
operation_type_rec = self.partner_picking_type_id
if not operation_type_rec:
operation_type_vals = {
"name": operation_type_name,
"code": "incoming",
"sequence_code": sequence_code,
}
if warehouse:
operation_type_vals.update({"warehouse_id": warehouse.id})
if location:
operation_type_vals.update({"default_location_dest_id": location.id})
operation_type_rec = self.env["stock.picking.type"].create(
operation_type_vals
)
return operation_type_rec
def _create_subcontracted_buy_rule(self, operation_type_rec, location):
"""Creating Route Rule for Subcontracting starts here"""
first_name = self.name.split(" ")[0] or ""
buy_route = self.env.ref(
"purchase_stock.route_warehouse0_buy", raise_if_not_found=False
)
rule_vals = {
"name": "Subcontractor {}".format(first_name),
"action": "buy",
}
rule = self.partner_buy_rule_id
if operation_type_rec:
rule_vals.update({"picking_type_id": operation_type_rec.id})
if location:
rule_vals.update({"location_id": location.id})
if buy_route:
rule_vals.update({"route_id": buy_route.id})
if not rule and rule_vals:
rule = self.env["stock.rule"].create(rule_vals)
return rule
def _create_subcontracted_resupply_rule(self, location):
"""# Creating Route Rule for Subcontracting resupply on order starts here"""
first_name = self.name.split(" ")[0] or ""
resupply_on_order_route = self.env.ref(
"mrp_subcontracting.route_resupply_subcontractor_mto",
raise_if_not_found=False,
)
delivery_type = self.env.ref("stock.picking_type_out", raise_if_not_found=False)
production = self.env["ir.property"]._get(
"property_stock_production", "product.template"
)
resupply_rule_vals = {
"name": "Subcontractor {}".format(first_name),
"action": "pull",
"partner_address_id": self._origin.id,
}
pull_rule = self.partner_resupply_rule_id
if delivery_type:
resupply_rule_vals.update(
{
"picking_type_id": delivery_type.id,
}
)
if location:
resupply_rule_vals.update(
{
"location_id": location.id,
}
)
if production:
resupply_rule_vals.update(
{
"location_src_id": production.id,
}
)
if resupply_on_order_route:
resupply_rule_vals.update(
{
"route_id": resupply_on_order_route.id,
}
)
if not pull_rule and resupply_rule_vals:
pull_rule = self.env["stock.rule"].create(resupply_rule_vals)
return pull_rule
def _create_subcontractor_entities(self):
"""
Create entities for the subcontractor
- Stock location
- Stock operation type
- "Buy" stock rule
"""
for rec in self.filtered(lambda p: p.company_type == "company"):
partner_update_vals = rec._create_subcontractor_entities_for_record()
rec.write(partner_update_vals)
def _update_subcontractor_entities_for_record(self, values):
self.ensure_one()
is_subcontractor_partner = values.get("is_subcontractor_partner")
check_data = {
# Updating Subcontracting Location
"subcontracted_created_location_id": self._create_subcontracting_location_data,
# Updating Subcontracting operation type
"partner_picking_type_id": self._create_operation_type_for_subcontracting,
# Updating Route Rule for Subcontracting buy
"partner_buy_rule_id": self._create_route_rule_for_subcontracting,
# Updating Route Rule for Subcontracting resupply
"partner_resupply_rule_id": self._create_route_rule_for_subcontracting_resupply,
}
for field_name in check_data:
if is_subcontractor_partner is True and getattr(self, field_name):
getattr(self, field_name).active = True
elif is_subcontractor_partner is True and not getattr(self, field_name):
values.update(check_data[field_name]())
elif is_subcontractor_partner is False and getattr(self, field_name):
getattr(self, field_name).active = False
return values
def _create_subcontractor_entities_for_record(self):
self.ensure_one()
partner_update_vals = {"is_subcontractor_partner": True}
# Creating Subcontracting Location ends here
partner_update_vals.update(self._create_subcontracting_location_data())
partner_update_vals.update(self._create_operation_type_for_subcontracting())
# Creating Route Rule for Subcontracting starts here
partner_update_vals.update(self._create_route_rule_for_subcontracting())
# Creating Route Rule for Subcontracting resupply on order starts here
partner_update_vals.update(
self._create_route_rule_for_subcontracting_resupply()
)
return partner_update_vals
def _get_location_for_record(self):
self.ensure_one()
location = self.subcontracted_created_location_id
if not location:
default_company = self.env.company
company = self.company_id or default_company
parent_location = (
company.subcontracting_location_id
and company.subcontracting_location_id.id
)
location = self._create_location(parent_location, company)
self.subcontracted_created_location_id = location
return location
def _get_warehouse_for_record(self):
self.ensure_one()
default_company = self.env.company
default_warehouse = self.env["stock.warehouse"].search(
[("company_id", "=", default_company.id)]
)[0]
company = self.company_id or default_company
warehouse = (
self.env["stock.warehouse"].search([("company_id", "=", company.id)])[0]
if self.company_id
else default_warehouse
) # noqa
return warehouse
def _create_subcontracting_location_data(self):
self.ensure_one()
location = self._get_location_for_record()
return {
"property_stock_subcontractor": location.id,
"subcontracted_created_location_id": location.id,
}
def _create_operation_type_for_subcontracting(self):
self.ensure_one()
operation_type_rec = self.partner_picking_type_id
if not operation_type_rec:
# Creating Operation Type for Subcontracting starts here
location = self._get_location_for_record()
warehouse = self._get_warehouse_for_record()
operation_type_rec = self._create_subcontracted_operation_type(
warehouse, location
)
self.partner_picking_type_id = operation_type_rec
return {"partner_picking_type_id": operation_type_rec.id}
def _create_route_rule_for_subcontracting(self):
location = self._get_location_for_record()
warehouse = self._get_warehouse_for_record()
operation_type_rec = self._create_subcontracted_operation_type(
warehouse, location
)
buy_rule = self._create_subcontracted_buy_rule(operation_type_rec, location)
return {"partner_buy_rule_id": buy_rule.id}
def _create_route_rule_for_subcontracting_resupply(self):
location = self._get_location_for_record()
resupply_rule = self._create_subcontracted_resupply_rule(location)
return {"partner_resupply_rule_id": resupply_rule.id}

View File

@@ -0,0 +1 @@
* No configuration is required

View File

@@ -0,0 +1,2 @@
* Ooops404 <https://www.ooops404.com/>
* Cetmix <https://cetmix.com/>

View File

@@ -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

View File

@@ -0,0 +1,4 @@
14.0.1.0.0
~~~~~~~~~~
* Initial release

View File

@@ -0,0 +1,4 @@
* 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1,458 @@
<?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 0.15.1: http://docutils.sourceforge.net/" />
<title>Subcontracting Partner Management</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/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. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" 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" href="https://github.com/OCA/manufacture/tree/14.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" href="https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-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" href="https://runbot.odoo-community.org/runbot/129/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-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="id2">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="id3">Usage</a></li>
<li><a class="reference internal" href="#changelog" id="id4">Changelog</a><ul>
<li><a class="reference internal" href="#id1" id="id5">14.0.1.0.0</a></li>
</ul>
</li>
<li><a class="reference internal" href="#bug-tracker" id="id6">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id7">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id8">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id9">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id10">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id2">Configuration</a></h1>
<ul class="simple">
<li>No configuration is required</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id3">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>
</ul>
</div>
<div class="section" id="changelog">
<h1><a class="toc-backref" href="#id4">Changelog</a></h1>
<div class="section" id="id1">
<h2><a class="toc-backref" href="#id5">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="#id6">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 smashing 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:%2014.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="#id7">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id8">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="#id9">Contributors</a></h2>
<ul class="simple">
<li>Ooops404 &lt;<a class="reference external" href="https://www.ooops404.com/">https://www.ooops404.com/</a>&gt;</li>
<li>Cetmix &lt;<a class="reference external" href="https://cetmix.com/">https://cetmix.com/</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id10">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/14.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>

View File

@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import test_create_sybcontractor_partner_location

View File

@@ -0,0 +1,170 @@
from odoo.tests import common, tagged
@tagged("post_install", "-at_install")
class TestSubcontractedPartner(common.SavepointCase):
@classmethod
def setUpClass(cls):
"""
- Create a Partner record “Wood Corner”
- Type will be Company and new boolean is_subcontractor_partner is Set True
"""
super().setUpClass()
cls.partner_id = cls.env.ref("base.res_partner_12")
cls.partner_obj = cls.env["res.partner"]
def _get_partner(self):
return self.partner_obj.create(
{
"name": "Test partner",
"is_company": True,
"is_subcontractor_partner": True,
}
)
def test_is_subcontractor_partner_first_time(self):
self.partner_id.update(
{
"is_subcontractor_partner": True,
}
)
location = self.partner_id.subcontracted_created_location_id
self.assertTrue(location, "Location is not created")
self.assertTrue(location.active, "Location must be active")
partner_picking_type = self.partner_id.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_id.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_id.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_id.write(
{
"is_subcontractor_partner": True,
}
)
self.partner_id.update(
{
"is_subcontractor_partner": False,
}
)
location = self.partner_id.subcontracted_created_location_id
self.assertFalse(location.active, "Location must be not active")
partner_picking_type = self.partner_id.partner_picking_type_id
self.assertFalse(partner_picking_type.active, "Picking type must be not active")
partner_buy_rule = self.partner_id.partner_buy_rule_id
self.assertFalse(partner_buy_rule.active, "Partner Buy rule must be not active")
partner_resupply_rule = self.partner_id.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_id.update(
{
"is_subcontractor_partner": True,
}
)
location = self.partner_id.subcontracted_created_location_id
self.assertTrue(location.active, "Location must be active")
partner_picking_type = self.partner_id.partner_picking_type_id
self.assertTrue(partner_picking_type.active, "Picking type must be active")
partner_buy_rule = self.partner_id.partner_buy_rule_id
self.assertTrue(partner_buy_rule.active, "Partner Buy rule must be active")
partner_resupply_rule = self.partner_id.partner_resupply_rule_id
self.assertTrue(
partner_resupply_rule.active, "Partner Resupply rule must be active"
)
def test_is_subcontractor_partner_aсtive_switch_off(self):
self.partner_id.write(
{
"is_subcontractor_partner": True,
}
)
self.partner_id.update(
{
"active": False,
}
)
location = self.partner_id.subcontracted_created_location_id
self.assertFalse(location.active, "Location must be not active")
partner_picking_type = self.partner_id.partner_picking_type_id
self.assertFalse(partner_picking_type.active, "Picking type must be not active")
partner_buy_rule = self.partner_id.partner_buy_rule_id
self.assertFalse(partner_buy_rule.active, "Partner Buy rule must be not active")
partner_resupply_rule = self.partner_id.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_id.write(
{
"is_subcontractor_partner": True,
}
)
self.partner_id.write(
{
"active": True,
}
)
location = self.partner_id.subcontracted_created_location_id
self.assertTrue(location.active, "Location must be active")
partner_picking_type = self.partner_id.partner_picking_type_id
self.assertTrue(partner_picking_type.active, "Picking type must be active")
partner_buy_rule = self.partner_id.partner_buy_rule_id
self.assertTrue(partner_buy_rule.active, "Partner Buy rule must be active")
partner_resupply_rule = self.partner_id.partner_resupply_rule_id
self.assertTrue(
partner_resupply_rule.active, "Partner Resupply rule must be active"
)
def test_is_subcontractor_partner_delete(self):
partner_id = self.partner_obj.create(
{
"name": "Test partner",
"is_company": True,
"is_subcontractor_partner": True,
}
)
location = partner_id.subcontracted_created_location_id
partner_picking_type = partner_id.partner_picking_type_id
partner_buy_rule = partner_id.partner_buy_rule_id
partner_resupply_rule = partner_id.partner_resupply_rule_id
partner_id.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"
)

View File

@@ -0,0 +1,20 @@
<?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="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='parent_id']" position="before">
<group name="is_partner_subcontractor">
<field
name="is_subcontractor_partner"
string="Subcontractor"
attrs="{'invisible': [('is_company', '=', False)]}"
/>
</group>
</xpath>
</field>
</record>
</odoo>