Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG] product_packaging_type: Migration to 14.0 #760

Merged
merged 32 commits into from Apr 9, 2021

Conversation

phuctranfxvn
Copy link
Contributor

No description provided.

damdam-s and others added 30 commits December 26, 2020 22:55
**Context**

* Manage UNECE codes on packaging
* Be able to express a packaging qty in smallest packaging qty
* Simplify packaging name management to ease translation and avoid people to write a name every time they add a packaging on a product

**Usage**

When I open a product form, in the inventory tab I want to see the product packaging and its related code I can quickly see the Qty per packaging to know how much of a given packaging is contain in another

**TODO**

* Update (Improve) the module "product_packaging_type" from product-attribute (I think ) to:
    * in the product "Inventory" tab form (Packaging list view)
        * Hide the name of the packaging
        * Move the "Packaging type" in the first position
    * When opening the packaging form view from  "Inventory" tab of the product
        * Replace the name by packaging type at the top
        * Hide name field, but populate it with on_change of packaging with the packaging type name
    * Name of the packaging type:
        * name_get should be: "NAME + ' ' + (CODE)" -> e.g. Retail box (HV)
        * name_get of the product packaging should be overridden:

```python
            if product_id is set:
                return packaging_type name (e.g. Transport box)
            else:
                return the recorded packaging name on the packaging (e.g. DHL box)
```
The constraint was added by module
OCA/stock-logistics-warehouse::stock_cubiscan, which makes no sense, see:
https://github.com/OCA/stock-logistics-warehouse/blob/95cc85c470dcdf6f41cec828e39beac4a9786c80/stock_cubiscan/models/stock.py#L15-L26

We should have only one type of packaging per product, but there is a
twist for the default packaging.

As the packaging type is required on a package, to be a good player with
other modules and existing data, a default packaging type is created,
and is used as a default value.

An existing database with 4 packaging per product will have the default
on all the packagings. So the unique constraint ignores the default
type, allowing users to transition to the proper types.
…False

In product packaging form view the "Has GTIN" is invisible
The SQL constraint I added previously [0] prevent some demo data to
be installed (e.g. in module OCA/wms::stock_storage_type).

The issue is that the packaging type is required, is part of the unique
constraint, and has a default packaging type.
When the module is installed and we have existing data or demo data,
the default type will be set on all the packagings, meaning we have
to ignore the unique constraint on the default type.
This was already handled using an "EXCLUDE" constraint, but it does
not solve the issue with demo data, the related field
"packaging_type_is_default", used as exclusion for the unique
constraint, is first inserted with a NULL value before being set
to True.

[0] OCA#654
Currently translated at 100.0% (25 of 25 strings)

Translation: product-attribute-13.0/product-attribute-13.0-product_packaging_type
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-13-0/product-attribute-13-0-product_packaging_type/es/
@phuctranfxvn phuctranfxvn mentioned this pull request Dec 26, 2020
44 tasks
Copy link
Member

@rvalyi rvalyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve the migration through basically it only consists in changing the version number to 14, so I'm not too sure if it is fair to make you a listed module contributor (this would not scale). I guess this is to be decided with CampToCamp authors. cc @damdam-s @jgrandguillaume

@sebastienbeau
Copy link
Member

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 14.0-ocabot-merge-pr-760-by-sebastienbeau-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 821c4ed into OCA:14.0 Apr 9, 2021
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 45e19d9. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet