[FIX] nfu_product: Relate package companies to products
This commit is contained in:
parent
dbc3b32ecd
commit
f38049fbf0
7 changed files with 8 additions and 38 deletions
|
|
@ -22,6 +22,7 @@ NFU Product
|
||||||
|
|
||||||
|badge1| |badge2| |badge3|
|
|badge1| |badge2| |badge3|
|
||||||
|
|
||||||
|
* Relate company_ids from packages to product.product
|
||||||
* Remove company_id and add company_ids to views
|
* Remove company_id and add company_ids to views
|
||||||
|
|
||||||
**Table of contents**
|
**Table of contents**
|
||||||
|
|
@ -35,6 +36,7 @@ Changelog
|
||||||
- 16.0.1.0.0: Initial module.
|
- 16.0.1.0.0: Initial module.
|
||||||
- 16.0.1.1.0: Add multi company to product packagings
|
- 16.0.1.1.0: Add multi company to product packagings
|
||||||
- 16.0.1.1.1: Avoid unvalid packaging companies
|
- 16.0.1.1.1: Avoid unvalid packaging companies
|
||||||
|
- 16.0.1.2.0: Relate package companies to products
|
||||||
|
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
from . import product_packaging
|
from . import product_packaging
|
||||||
from . import product_product
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
from odoo import api, models
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
class ProductPackaging(models.Model):
|
class ProductPackaging(models.Model):
|
||||||
_inherit = ["multi.company.abstract", "product.packaging"]
|
_inherit = ["multi.company.abstract", "product.packaging"]
|
||||||
_name = "product.packaging"
|
_name = "product.packaging"
|
||||||
|
|
||||||
@api.model_create_multi
|
company_ids = fields.Many2many(related="product_id.company_ids")
|
||||||
def create(self, vals_list):
|
|
||||||
for vals in vals_list:
|
|
||||||
product = self.env["product.product"].browse(vals.get("product_id"))
|
|
||||||
vals["company_ids"] = [(6, 0, product.company_ids.ids)]
|
|
||||||
res = super().create(vals_list)
|
|
||||||
return res
|
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
from odoo import models
|
|
||||||
|
|
||||||
|
|
||||||
class ProductProduct(models.Model):
|
|
||||||
_inherit = "product.product"
|
|
||||||
|
|
||||||
def write(self, vals):
|
|
||||||
if "company_ids" in vals:
|
|
||||||
for product in self:
|
|
||||||
company_ids = vals.get("company_ids", [])[0][2]
|
|
||||||
if company_ids:
|
|
||||||
related_packages = self.env["product.packaging"].search(
|
|
||||||
[("product_id", "=", product.id)]
|
|
||||||
)
|
|
||||||
|
|
||||||
# First, set the company_ids on packages if not set
|
|
||||||
for package in related_packages:
|
|
||||||
if not package.company_ids:
|
|
||||||
package.company_ids = product.company_ids
|
|
||||||
else:
|
|
||||||
allowed_company_ids = list(
|
|
||||||
set(package.company_ids.ids) & set(company_ids)
|
|
||||||
)
|
|
||||||
if not allowed_company_ids:
|
|
||||||
package.company_ids = [(6, 0, company_ids)]
|
|
||||||
else:
|
|
||||||
package.company_ids = [(6, 0, allowed_company_ids)]
|
|
||||||
res = super().write(vals)
|
|
||||||
return res
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
* Relate company_ids from packages to product.product
|
||||||
* Remove company_id and add company_ids to views
|
* Remove company_id and add company_ids to views
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
- 16.0.1.0.0: Initial module.
|
- 16.0.1.0.0: Initial module.
|
||||||
- 16.0.1.1.0: Add multi company to product packagings
|
- 16.0.1.1.0: Add multi company to product packagings
|
||||||
- 16.0.1.1.1: Avoid unvalid packaging companies
|
- 16.0.1.1.1: Avoid unvalid packaging companies
|
||||||
|
- 16.0.1.2.0: Relate package companies to products
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -371,6 +371,7 @@ ul.auto-toc {
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<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/bruecksen/nfu/tree/16.0/nfu_product"><img alt="bruecksen/nfu" src="https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github" /></a></p>
|
<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/bruecksen/nfu/tree/16.0/nfu_product"><img alt="bruecksen/nfu" src="https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github" /></a></p>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
|
<li>Relate company_ids from packages to product.product</li>
|
||||||
<li>Remove company_id and add company_ids to views</li>
|
<li>Remove company_id and add company_ids to views</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>Table of contents</strong></p>
|
<p><strong>Table of contents</strong></p>
|
||||||
|
|
@ -392,6 +393,7 @@ ul.auto-toc {
|
||||||
<li>16.0.1.0.0: Initial module.</li>
|
<li>16.0.1.0.0: Initial module.</li>
|
||||||
<li>16.0.1.1.0: Add multi company to product packagings</li>
|
<li>16.0.1.1.0: Add multi company to product packagings</li>
|
||||||
<li>16.0.1.1.1: Avoid unvalid packaging companies</li>
|
<li>16.0.1.1.1: Avoid unvalid packaging companies</li>
|
||||||
|
<li>16.0.1.2.0: Relate package companies to products</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue