mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[FIX] mrp_subcontracting_partner_management : Changed create function.
[UPD] Update mrp_subcontracting_partner_management.pot [UPD] README.rst mrp_subcontracting_partner_management 14.0.2.0.0 Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: manufacture-14.0/manufacture-14.0-mrp_subcontracting_partner_management Translate-URL: https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-mrp_subcontracting_partner_management/
This commit is contained in:
committed by
Víctor Martínez
parent
cd20343a80
commit
7bd03bd56f
@@ -42,7 +42,10 @@ It adds a new checkbox "Subcontractor" which when enabled creates the following
|
||||
Configuration
|
||||
=============
|
||||
|
||||
* No configuration is required
|
||||
To see newly created rules, go to **Settings** > **Inventory** and activate "Multi step routes".
|
||||
|
||||
It is also possible to allow a user to check inventory locations in **Sales & Purchases** tab of **Vendor** without activating dev mode.
|
||||
To do so, enable technical extra right **Display Inventory section on Vendor** in user.
|
||||
|
||||
Usage
|
||||
=====
|
||||
@@ -51,6 +54,9 @@ Usage
|
||||
* 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.
|
||||
* When name of subcontractor is updated, names of entities (subcontracting location, operation type, rules) are updated automatically.
|
||||
|
||||
Changelog
|
||||
=========
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Subcontracting Partner Management",
|
||||
"version": "14.0.1.1.0",
|
||||
"version": "14.0.2.0.0",
|
||||
"summary": "Subcontracting Partner Management",
|
||||
"author": "Ooops404, Cetmix, Odoo Community Association (OCA)",
|
||||
"license": "LGPL-3",
|
||||
|
||||
@@ -76,7 +76,11 @@ 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_partner_form_inherit_subcontractor
|
||||
#: 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 ""
|
||||
|
||||
@@ -76,7 +76,11 @@ msgstr "Ubicazione 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_partner_form_inherit_subcontractor
|
||||
#: 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 ""
|
||||
|
||||
@@ -73,7 +73,11 @@ 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
|
||||
#: 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 ""
|
||||
|
||||
@@ -95,18 +95,20 @@ class ResPartner(models.Model):
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
records = super(ResPartner, self).create(vals_list)
|
||||
check_data = self.get_data_struct().items()
|
||||
for record in records.filtered(
|
||||
lambda r: r.is_subcontractor_partner and r.is_company
|
||||
for vals in filter(
|
||||
lambda v: v.get("is_subcontractor_partner") and v.get("is_company"),
|
||||
vals_list,
|
||||
):
|
||||
values = {}
|
||||
for key, func in check_data:
|
||||
if not getattr(record, key) or not values.get(key):
|
||||
values.update(**getattr(record, func)(values) or {})
|
||||
if values:
|
||||
record.write(values)
|
||||
return records
|
||||
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(ResPartner, self).create(vals_list)
|
||||
|
||||
def _update_subcontractor_entities_for_record(self, is_subcontractor_partner):
|
||||
if not is_subcontractor_partner:
|
||||
@@ -139,7 +141,9 @@ class ResPartner(models.Model):
|
||||
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._compose_entity_name()
|
||||
operation_type_name = "%s: IN" % self._context.get(
|
||||
"partner_name", self._compose_entity_name()
|
||||
)
|
||||
operation_type_vals = {
|
||||
"name": operation_type_name,
|
||||
"code": "incoming",
|
||||
@@ -160,7 +164,6 @@ class ResPartner(models.Model):
|
||||
)
|
||||
|
||||
def _get_location_id_for_record(self, vals):
|
||||
self.ensure_one()
|
||||
if "subcontracted_created_location_id" in vals:
|
||||
return vals.get("subcontracted_created_location_id")
|
||||
if self.subcontracted_created_location_id:
|
||||
@@ -173,7 +176,9 @@ class ResPartner(models.Model):
|
||||
self.env["stock.location"]
|
||||
.create(
|
||||
{
|
||||
"name": self._compose_entity_name(),
|
||||
"name": self._context.get(
|
||||
"partner_name", self._compose_entity_name()
|
||||
),
|
||||
"usage": "internal",
|
||||
"location_id": parent_location or False,
|
||||
"company_id": company.id,
|
||||
@@ -184,7 +189,6 @@ class ResPartner(models.Model):
|
||||
)
|
||||
|
||||
def _create_subcontracting_location_data(self, vals):
|
||||
self.ensure_one()
|
||||
location_id = self._get_location_id_for_record(vals)
|
||||
return {
|
||||
"property_stock_subcontractor": location_id,
|
||||
@@ -192,13 +196,11 @@ class ResPartner(models.Model):
|
||||
}
|
||||
|
||||
def _create_operation_type_for_subcontracting(self, vals):
|
||||
self.ensure_one()
|
||||
# Creating Operation Type for Subcontracting starts here
|
||||
operation_type_rec_id, _ = self._create_subcontracted_operation_type(vals)
|
||||
return {"partner_picking_type_id": operation_type_rec_id}
|
||||
|
||||
def _create_route_rule_for_subcontracting(self, vals):
|
||||
self.ensure_one()
|
||||
operation_type_rec_id, location_id = self._create_subcontracted_operation_type(
|
||||
vals
|
||||
)
|
||||
@@ -207,7 +209,7 @@ class ResPartner(models.Model):
|
||||
)
|
||||
buy_rule = self.env["stock.rule"].create(
|
||||
{
|
||||
"name": self._compose_entity_name(),
|
||||
"name": self._context.get("partner_name", self._compose_entity_name()),
|
||||
"action": "buy",
|
||||
"picking_type_id": operation_type_rec_id,
|
||||
"location_id": location_id,
|
||||
@@ -217,7 +219,6 @@ class ResPartner(models.Model):
|
||||
return {"partner_buy_rule_id": buy_rule.id}
|
||||
|
||||
def _create_route_rule_for_subcontracting_resupply(self, vals):
|
||||
self.ensure_one()
|
||||
prop = self.env["ir.property"]._get(
|
||||
"property_stock_production", "product.template"
|
||||
)
|
||||
@@ -228,7 +229,7 @@ class ResPartner(models.Model):
|
||||
)
|
||||
rule = self.env["stock.rule"].create(
|
||||
{
|
||||
"name": self._compose_entity_name(),
|
||||
"name": self._context.get("partner_name", self._compose_entity_name()),
|
||||
"action": "pull",
|
||||
"partner_address_id": self._origin.id,
|
||||
"picking_type_id": picking_type.id,
|
||||
|
||||
@@ -397,9 +397,9 @@ ul.auto-toc {
|
||||
</div>
|
||||
<div class="section" id="configuration">
|
||||
<h1><a class="toc-backref" href="#id3">Configuration</a></h1>
|
||||
<ul class="simple">
|
||||
<li>No configuration is required</li>
|
||||
</ul>
|
||||
<p>To see newly created rules, go to <strong>Settings</strong> > <strong>Inventory</strong> and activate “Multi step routes”.</p>
|
||||
<p>It is also possible to allow a user to check inventory locations in <strong>Sales & Purchases</strong> tab of <strong>Vendor</strong> without activating dev mode.
|
||||
To do so, enable technical extra right <strong>Display Inventory section on Vendor</strong> in user.</p>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#id4">Usage</a></h1>
|
||||
@@ -408,6 +408,9 @@ ul.auto-toc {
|
||||
<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>
|
||||
<li>When name of subcontractor is updated, names of entities (subcontracting location, operation type, rules) are updated automatically.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="changelog">
|
||||
|
||||
Reference in New Issue
Block a user