-
-
Notifications
You must be signed in to change notification settings - Fork 699
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
[11.0][MIG] account_invoice_supplier_ref_unique #347
Conversation
…work with different langage within same instance + add bwrsandman code suggestion
…he constraint against + make the error message to be translatable
…que: the contraint is now applied to all records modified; not only the first one.
Add bugtracker section in README.rst
[MIG] account_invoice_supplier_ref_unique: Migration to 9.0
* Update fr_CH.po * Update fr.po
Isn't this check already in core? |
@pedrobaeza it seems to me that this module is still needed. The 'Vendor invoice number' is an information not present in the account module. |
Are you sure? Then, why this only depends on |
@pedrobaeza sorry, I think I'm not understanding your point. This module adds a field on the vendor invoice, so there's no need of extra dependencies. Or maybe I'm missing something? |
Ah, sorry, it was me then. The module name has confused me. I thought it was for having an unique supplier invoice number, but on the existing 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 have tested the 'uniqueness the invoice supplier ref field and it works correct (tested internally and on runbot)
# Copyright 2016 Acsone | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models, fields, api, _ |
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.
Imports should be sorted Alphabetically
from odoo import api, fields, models, _
if self.supplier_invoice_number and\ | ||
self.type in ('in_invoice', 'in_refund'): | ||
same_supplier_inv_num = self.search([ | ||
('commercial_partner_id', '=', self.commercial_partner_id.id), |
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 company_id
?
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.
Shouldn't supplier_invoice_number be unique, regardless of the company_id?
In a multicompany environment, if you create two invoices in two different companies with the same vendor and the same supplier_invoice_number, you should still raise the ValidationError.
Did I understand your point correctly? Is this the case you are talking about?
('supplier_invoice_number', | ||
'=ilike', | ||
self.supplier_invoice_number), | ||
('id', '!=', self.id), ]) |
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.
limit=1
in order to avoid use index [0] in the line 38 same_supplier_inv_num[0].supplier_invoice_number
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.
Yes indeed! Thank you.
@moylop260 are you ok with my answer? Can we merge this one? |
Porting of
account_invoice_supplier_ref_unique
to V11