-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
Conversation
vnikolayev1
commented
May 29, 2024
- 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.
[UPD] Update shipment_advice.pot
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.
From the migration task, access to ir.actions.* needs sudo now... https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-14.0#tasks-to-do-in-the-migration
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.
[UPD] Update stock_dock.pot
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/
476b56b
to
4dc3221
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing.
cf9d5aa
to
458fad1
Compare
@vnikolayev1 Thanks for your contribution Could you check the pre-commit issue and the failing tests ? |
There was a problem hiding this comment.
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/
5057166
to
315c0d6
Compare
315c0d6
to
7bfce51
Compare
shipment_advice_auto_validate = fields.Boolean( | ||
string="Enable Shipment Advice Auto Validation", | ||
config_parameter='shipment_advice.shipment_advice_auto_validate', | ||
) |
There was a problem hiding this comment.
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.
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", | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly=False
shipment_advice/models/stock_move.py
Outdated
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() |
There was a problem hiding this comment.
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
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() |
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") |
There was a problem hiding this comment.
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.
0a8d74a
to
9d98dd3
Compare
- 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.
9d98dd3
to
f0a4e11
Compare
messed up with rebase, created new one #128 |