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
[FIX] product_unique_serial: validated quants reservation in stock.serial #20
Conversation
Hi @JulioSerna, Can you give me your +1 ??? Thanks, |
}} | ||
else: | ||
serial.append(serial_name.serial) | ||
serials = [serial.serial for serial in self.serial_ids] |
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.
I think you can use self.serial_ids.mapped('serial')
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.
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
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.
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
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.
@@ -156,47 +174,18 @@ class StockSerialLine(models.TransientModel): | |||
|
|||
_name = 'stock.serial.line' | |||
|
|||
@api.multi | |||
@api.depends('serial') | |||
def _compute_lot_id(self): |
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.
why this function field?
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.
i think that looks better that load lot_id
by a onchange
method
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.
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
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 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?
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.
I am agree with function field
1bdcafb
to
986c1b7
Compare
hi @JulioSerna your feedback is now ready... can you do a last check and give a +1??? Thanks, |
Hi @moylop260 Can you merge this please??? Thanks, |
986c1b7
to
0eb6516
Compare
…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.
hi @moylop260, I made the constraints that you suggested me, also a test for this case! By me side is ready to merge Regards, |
The red in runbot has no relation with the PR: |
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.) |
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.
Also in this PR:
lot_id
in compute field