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

[ADD][REF] shipment_advice #126

Closed
wants to merge 179 commits into from

Conversation

vnikolayev1
Copy link

  • modified shipment_advice, so it has validate_when_fully_done method that sets shipment to done if its moves are in "done" state, updated tests.

OCA-git-bot and others added 30 commits October 3, 2022 22:07
The name field was not filled with its default value '/' when the
shipment was created from the calendar view.
Ensure we get the default value '/' in name field through the action.
When testing with `shopfloor_delivery_shipment` module, there was error
in this module as below. That is because normal stock user is used in
testing. So this commit is to add test with normal stock user to make
sure UI works as expected.

```
odoo.exceptions.AccessError: You are not allowed to access 'Action Window' (ir.actions.act_window) records.

This operation is allowed for the following groups:
        - Administration/Settings

Contact your administrator to request access if necessary.
```
And filter available docks from a shipment to the current warehouse.
victorvermot and others added 8 commits April 3, 2024 12:59
Signed-off-by sebalix
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: stock-logistics-transport-16.0/stock-logistics-transport-16.0-shipment_advice
Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-transport-16-0/stock-logistics-transport-16-0-shipment_advice/
Currently translated at 99.5% (225 of 226 strings)

Translation: stock-logistics-transport-16.0/stock-logistics-transport-16.0-shipment_advice
Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-transport-16-0/stock-logistics-transport-16-0-shipment_advice/it/
Currently translated at 100.0% (226 of 226 strings)

Translation: stock-logistics-transport-16.0/stock-logistics-transport-16.0-shipment_advice
Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-transport-16-0/stock-logistics-transport-16-0-shipment_advice/it/
@vnikolayev1
Copy link
Author

@mt-software-de

@vnikolayev1 vnikolayev1 force-pushed the 14.0-shipment_advice_done_ref branch from 476b56b to 4dc3221 Compare May 29, 2024 14:11
Copy link
Contributor

@mt-software-de mt-software-de left a comment

Choose a reason for hiding this comment

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

Thanks for contributing.

shipment_advice/models/shipment_advice.py Outdated Show resolved Hide resolved
shipment_advice/tests/test_shipment_advice.py Show resolved Hide resolved
@vnikolayev1 vnikolayev1 force-pushed the 14.0-shipment_advice_done_ref branch 2 times, most recently from cf9d5aa to 458fad1 Compare May 30, 2024 11:57
@TDu
Copy link
Member

TDu commented Jun 4, 2024

@vnikolayev1 Thanks for your contribution Could you check the pre-commit issue and the failing tests ?
Also you may already have seen it but there is this https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst document that give lots of tips and guidelines.
Could you read the part on commit message https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#git and update your commit message for this one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please do not change the existing tests, it is not needed.

Currently translated at 100.0% (226 of 226 strings)

Translation: stock-logistics-transport-16.0/stock-logistics-transport-16.0-shipment_advice
Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-transport-16-0/stock-logistics-transport-16-0-shipment_advice/it/
@vnikolayev1 vnikolayev1 force-pushed the 14.0-shipment_advice_done_ref branch 3 times, most recently from 5057166 to 315c0d6 Compare June 11, 2024 10:12
@vnikolayev1 vnikolayev1 force-pushed the 14.0-shipment_advice_done_ref branch from 315c0d6 to 7bfce51 Compare June 19, 2024 06:06
Comment on lines 13 to 15
shipment_advice_auto_validate = fields.Boolean(
string="Enable Shipment Advice Auto Validation",
config_parameter='shipment_advice.shipment_advice_auto_validate',
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a related field to the company.

Suggested change
shipment_advice_auto_validate = fields.Boolean(
string="Enable Shipment Advice Auto Validation",
config_parameter='shipment_advice.shipment_advice_auto_validate',
)
shipment_advice_auto_validate = fields.Boolean(
related="company_id.shipment_advice_auto_validate",
)

Choose a reason for hiding this comment

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

readonly=False

Comment on lines 22 to 28
res = super()._action_done(cancel_backorder=cancel_backorder)
for rec in self:
if rec.shipment_advice_id.shipment_type == "incoming":
auto_validate_enabled = self.env['ir.config_parameter'].sudo().get_param(
'shipment_advice.shipment_advice_auto_validate', default=False)
if auto_validate_enabled:
rec.shipment_advice_id._action_done()
Copy link
Contributor

Choose a reason for hiding this comment

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

You have to care about the result of the super call, this is returning the moves which are actually done.
As well the shipment advice should only be closed if every move is done. There call your new create method validate_when_fully_done

Suggested change
res = super()._action_done(cancel_backorder=cancel_backorder)
for rec in self:
if rec.shipment_advice_id.shipment_type == "incoming":
auto_validate_enabled = self.env['ir.config_parameter'].sudo().get_param(
'shipment_advice.shipment_advice_auto_validate', default=False)
if auto_validate_enabled:
rec.shipment_advice_id._action_done()
res = super()._action_done(cancel_backorder=cancel_backorder)
shipment_advices = res.shipment_advice_id
for shipment_advice in shipment_advices:
if shipment_advice.shipment_type != "incoming" or shipment_advice.company_id.shipment_advice_auto_validate:
continue
shipment_advice.validate_when_fully_done()

Comment on lines 250 to 280
def test_validate_shipment_advice_when_fully_done(self):
picking = self._prepare_picking_with_two_packages()
line1, line2 = picking.move_line_ids
# Load first package in shipment advice 2
pl1 = line1.package_level_id
self._in_progress_shipment_advice(self.shipment_advice_out)
self.assertEqual(self.shipment_advice_out.state, "in_progress")
self._load_records_in_shipment(self.shipment_advice_out, pl1)
pl2 = line2.package_level_id
# Load second package into shipment advice
self._load_records_in_shipment(self.shipment_advice_out, pl2)
# Assign planned move_ids that are assigned to test function
self.shipment_advice_out.planned_move_ids = line2.move_id + line1.move_id
self.assertEqual(line1.move_id.state, "assigned")
self.assertEqual(line2.move_id.state, "assigned")
self.assertEqual(self.shipment_advice_out.state, "in_progress")
# Validating if moves in "incorrect" states do not trigger _action_done()
self.shipment_advice_out.validate_when_fully_done()
self.assertEqual(self.shipment_advice_out.state, "in_progress")
# Validating if moves in one "incorrect" state do not trigger _action_done()
line1.move_id.state = "done"
self.shipment_advice_out.validate_when_fully_done()
self.assertEqual(self.shipment_advice_out.state, "in_progress")
line2.move_id.state = "done"
self.shipment_advice_out.validate_when_fully_done()
self.assertEqual(self.shipment_advice_out.state, "done")
self.assertEqual(picking.state, "done")
Copy link
Contributor

Choose a reason for hiding this comment

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

In this test you should call the validate_when_full_done anymore.
I would be good to just validate the pickings. And afterwards check if the shipment advice is closed.

@rafaelbn rafaelbn added this to the 14.0 milestone Jun 19, 2024
@vnikolayev1 vnikolayev1 force-pushed the 14.0-shipment_advice_done_ref branch 2 times, most recently from 0a8d74a to 9d98dd3 Compare June 20, 2024 22:40
- modified shipment_advice, so whenever we set stock move to done, and if autovalidate shipment advice is enabled in company settings - we set shipment advice to done
- updated tests, covered backorder.
@vnikolayev1
Copy link
Author

messed up with rebase, created new one #128

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.