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

[FIX] product_unique_serial: validated quants reservation in stock.serial #20

Conversation

suniagajose
Copy link

Expected Behavior:
That the serial number selected through the move_line wizard remains reserved only for that stock.picking

Current Behaviour:
The same serial number can be used to make reservation in several pickings, but not at the same time.

5c511126-ac86-11e6-8d2c-8655e57cfa12

Also in this PR:

  • Improved functions performance (less if-else, less lines, removed function 'format' use, etc)
  • Replaced some warnings messages in 'onchange' by Validation Errors.
  • Converted lot_id in compute field
  • Added other validations

@suniagajose
Copy link
Author

Hi @JulioSerna,

Can you give me your +1 ???

Thanks,

}}
else:
serial.append(serial_name.serial)
serials = [serial.serial for serial in self.serial_ids]

Choose a reason for hiding this comment

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

I think you can use self.serial_ids.mapped('serial')

Copy link
Author

Choose a reason for hiding this comment

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

with a mapped i don't get repeated items, for that reason i use a comprehension list, to be able to get repeated items and display error message

Copy link

@moylop260 moylop260 Nov 20, 2016

Choose a reason for hiding this comment

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

What about create a unique-sql-constraint for stock.serial.line to avoid duplicated?
You could have the database healthy if you are using a different way to insert records (import csv files, create from webservices, sql inserts, create from other models)

I mean UNIQUE('serial_id', 'serial') from stock.serial.line
You can see real example here: odoo-10.0/addons/stock/models/stock_pack_operation.py#L267-L270

Copy link
Author

Choose a reason for hiding this comment

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

good idea @moylop260

i will do it!!!

thanks

@@ -156,47 +174,18 @@ class StockSerialLine(models.TransientModel):

_name = 'stock.serial.line'

@api.multi
@api.depends('serial')
def _compute_lot_id(self):

Choose a reason for hiding this comment

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

why this function field?

Copy link
Author

Choose a reason for hiding this comment

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

i think that looks better that load lot_id by a onchange method

Choose a reason for hiding this comment

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

but you are not considering all cases of the onchange like return
you are validating all cases when press button of the wizard and then if there are many serial captured and there is warning/exception in one of the serial the user does not know until end of process

Copy link
Author

Choose a reason for hiding this comment

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

you right! about give a warning to user using onchange, i will bring it back this functionality... but what you think about computed field? left only the onchange function?

Choose a reason for hiding this comment

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

I am agree with function field

@suniagajose suniagajose force-pushed the 8.0-fix-serial-reserved-product_unique_serial-dev-suniagajose branch from 1bdcafb to 986c1b7 Compare November 18, 2016 03:12
@suniagajose
Copy link
Author

hi @JulioSerna your feedback is now ready...

can you do a last check and give a +1???

Thanks,

@suniagajose
Copy link
Author

Hi @moylop260

Can you merge this please???

Thanks,

@suniagajose suniagajose force-pushed the 8.0-fix-serial-reserved-product_unique_serial-dev-suniagajose branch from 986c1b7 to 0eb6516 Compare November 21, 2016 01:43
…l wizard

Expected Behavior:
That the serial number selected through the move_line wizard remains
reserved only for that stock.picking

Current Behaviour:
The same serial number can be used to make reservation in several
pickings, but not at the same time.
@suniagajose
Copy link
Author

hi @moylop260,

I made the constraints that you suggested me, also a test for this case!

By me side is ready to merge

Regards,

@nhomar
Copy link
Member

nhomar commented Nov 21, 2016

The red in runbot has no relation with the PR:

@nhomar nhomar merged commit d51a4a9 into Vauxoo:8.0 Nov 21, 2016
@nhomar nhomar deleted the 8.0-fix-serial-reserved-product_unique_serial-dev-suniagajose branch November 21, 2016 20:13
@nhomar nhomar restored the 8.0-fix-serial-reserved-product_unique_serial-dev-suniagajose branch November 21, 2016 20:13
@nhomar
Copy link
Member

nhomar commented Nov 21, 2016

Sorry I merged without approval (My Mistake) if not problem I left it in this way, but if there is a problem please revert (branch is available.)

@moylop260 moylop260 deleted the 8.0-fix-serial-reserved-product_unique_serial-dev-suniagajose branch November 21, 2016 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants