manufacture icon indicating copy to clipboard operation
manufacture copied to clipboard

[16.0][MIG] mrp_bom_attribute_match

Open mymage opened this issue 2 years ago • 20 comments

mymage avatar Jan 03 '23 18:01 mymage

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

github-actions[bot] avatar May 07 '23 12:05 github-actions[bot]

@mymage If you are willing to reopen the PR I can make sure it gets merged this time (+2 reviewers)

(although some PRs with fixes have been merged in between)

giarve avatar Jan 09 '24 21:01 giarve

@giarve Thanks for your help. I think that only a PSC can reopen this PR so I ask @OCA/manufacturing-maintainers to do that, thanks.

mymage avatar Jan 10 '24 08:01 mymage

/ocabot migration mrp_bom_attribute_match

grindtildeath avatar Jan 10 '24 12:01 grindtildeath

Thanks @grindtildeath. @giarve Ops... there are some test to fix. I'll look on the WE if I'm able to solve it, if not I'll ask for your help ;-)

mymage avatar Jan 10 '24 13:01 mymage

Thanks @grindtildeath. @giarve Ops... there are some test to fix. I'll look on the WE if I'm able to solve it, if not I'll ask for your help ;-)

Great!

There are also these fixes available now

https://github.com/OCA/manufacture/pull/958

https://github.com/OCA/manufacture/pull/1090

https://github.com/OCA/manufacture/pull/1100

https://github.com/OCA/manufacture/pull/1172

giarve avatar Jan 10 '24 16:01 giarve

We also found another small problem. If you do not set this flag for the user

Untitled

it raises an error:

Untitled

The failing test may be unrelated (did not check yet)

giarve avatar Jan 11 '24 10:01 giarve

@mymage I found the solution. Replace the force_save and require attribute with this.

<xpath expr="//field[@name='bom_line_ids']//field[@name='product_uom_id']" position="after">
  <field name="product_uom_id" column_invisible="True" groups="!uom.group_uom"/>
</xpath>

it will enable the field even when the group disables it (it will send the uom to the client anyways but will be hidden)

You can re-enable the tests then, they will work. Tried on runboat.

I found this browsing Odoo source code

giarve avatar Jan 25 '24 20:01 giarve

@mymage I found the solution. Replace the force_save and require attribute with this.

@giarve thank you very much for your hint, now the problem is on another place... the war continues..

mymage avatar Jan 25 '24 21:01 mymage

@mymage @giarve feel free to check with maintainers @ivantodorovich or @ilyasProgrammer

francesco-ooops avatar Jan 26 '24 15:01 francesco-ooops

@mymage Well at least now it is not the product_uom_id anymore with the invisible="1"

It might error reading product_variant_ids now, but does seem something unrelated to the previous problem.

giarve avatar Jan 26 '24 19:01 giarve

@giarve Yeeeeeee! finally I got it! I converted it to draft because I haven't check for the fix PRs that you have indicated. If you are patient I will try to merge them in this PR (if this is the correct thing to do).

mymage avatar Jan 26 '24 20:01 mymage

@giarve Yeeeeeee! finally I got it! I converted it to draft because I haven't check for the fix PRs that you have indicated. If you are patient I will try to merge them in this PR (if this is the correct thing to do).

Yes, otherwise we can help. I think if you allow us to push to your fork we can add commits

giarve avatar Feb 01 '24 11:02 giarve

Yes, otherwise we can help. I think if you allow us to push to your fork we can add commits

@giarve I gave the authorisation to you. Let me know if I had to add more people. leave me at least one PR to include because I haven't had the chance to do this before.

mymage avatar Feb 01 '24 16:02 mymage

Yes, otherwise we can help. I think if you allow us to push to your fork we can add commits

@giarve I gave the authorisation to you. Let me know if I had to add more people. leave me at least one PR to include because I haven't had the chance to do this before.

Sorry I forgot about this. I will still be travelling for a few weeks, so you can pick the PR you want.

giarve avatar Feb 06 '24 09:02 giarve

@giarve sorry, I tried with the #958 but the problems come back so I went back to the original version. Let me know if you can do the cherry-picking yourself or if you want me to reactivate the PR and then import the fixes with new PRs

mymage avatar Feb 09 '24 21:02 mymage

@giarve sorry, I tried with the #958 but the problems come back so I went back to the original version. Let me know if you can do the cherry-picking yourself or if you want me to reactivate the PR and then import the fixes with new PRs

No problem. I made a new branch migrating from 14.0 which has the latest changes. I still have to test everything but with WinMerge it looked really similar to 15.0

https://github.com/wvbs/manufacture/commits/16.0-mig-mrp_bom_attribute_match/

You can use this branch from now on. I added your changes, but it has all the fixes for 14.0. We will have to see if tests pass (EDIT: they don't, I messed up somewhere when merging). Something else to consider is that we must also migrate mrp_account_bom_attribute_match with a new PR (EDIT: #1200)

I didn't want to force push on this PR without permission

giarve avatar Feb 10 '24 12:02 giarve

No problem. I made a new branch migrating from 14.0 ...

You are moving me to "new level" of cooperation: thank for your trust, I will do my best to complete this task.

mymage avatar Feb 10 '24 12:02 mymage

No problem. I made a new branch migrating from 14.0 ...

You are moving me to "new level" of cooperation: thank for your trust, I will do my best to complete this task.

More tests are passing now.

you can switch the branch in this PR to the new one if you wish.

mrp_report_bom_structure.py has to be rewritten entirely as the function names that were being overwritten are different in 16.0

giarve avatar Feb 11 '24 10:02 giarve

After a few fixes seems that only this button is still failing: image

Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5165, in ensure_one
    _id, = self._ids
ValueError: not enough values to unpack (expected 1, got 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1591, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "/opt/odoo/custom/src/odoo/odoo/service/model.py", line 133, in retrying
    result = func()
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1618, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1822, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_http.py", line 154, in _dispatch
    result = endpoint(**request.params)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 697, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "/opt/odoo/auto/addons/web/controllers/dataset.py", line 46, in call_button
    action = self._call_kw(model, method, args, kwargs)
  File "/opt/odoo/auto/addons/web/controllers/dataset.py", line 33, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/api.py", line 466, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/api.py", line 453, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/auto/addons/mrp_account/models/product.py", line 29, in button_bom_cost
    self._set_price_from_bom()
  File "/opt/odoo/auto/addons/mrp_account/models/product.py", line 40, in _set_price_from_bom
    self.standard_price = self._compute_bom_price(bom, boms_to_recompute=boms_to_recompute)
  File "/opt/odoo/auto/addons/mrp_subcontracting_account/models/product_product.py", line 12, in _compute_bom_price
    price = super()._compute_bom_price(bom, boms_to_recompute, byproduct_bom)
  File "/opt/odoo/auto/addons/mrp_account/models/product.py", line 93, in _compute_bom_price
    total += line.product_id.uom_id._compute_price(line.product_id.standard_price, line.product_uom_id) * line.product_qty
  File "/opt/odoo/auto/addons/uom/models/uom_uom.py", line 231, in _compute_price
    self.ensure_one()
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5168, in ensure_one
    raise ValueError("Expected singleton: %s" % self)
ValueError: Expected singleton: uom.uom()

giarve avatar Feb 11 '24 16:02 giarve