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

[11.0][MIG] account_invoice_supplier_ref_unique #347

Merged
merged 28 commits into from
Feb 1, 2018
Merged

[11.0][MIG] account_invoice_supplier_ref_unique #347

merged 28 commits into from
Feb 1, 2018

Conversation

astirpe
Copy link
Member

@astirpe astirpe commented Jan 2, 2018

Porting of account_invoice_supplier_ref_unique to V11

Marc Cassuto and others added 26 commits January 2, 2018 15:50
…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
@astirpe astirpe mentioned this pull request Jan 2, 2018
36 tasks
@pedrobaeza
Copy link
Member

Isn't this check already in core?

@pedrobaeza pedrobaeza added this to the 11.0 milestone Jan 2, 2018
@astirpe
Copy link
Member Author

astirpe commented Jan 2, 2018

@pedrobaeza it seems to me that this module is still needed. The 'Vendor invoice number' is an information not present in the account module.

@pedrobaeza
Copy link
Member

Are you sure? Then, why this only depends on account?

@astirpe
Copy link
Member Author

astirpe commented Jan 2, 2018

@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?

@pedrobaeza
Copy link
Member

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.

Copy link

@ThijsvOers ThijsvOers left a 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, _
Copy link
Member

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),
Copy link
Contributor

Choose a reason for hiding this comment

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

What about company_id?

Copy link
Member Author

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), ])
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes indeed! Thank you.

@astirpe
Copy link
Member Author

astirpe commented Feb 1, 2018

@moylop260 are you ok with my answer? Can we merge this one?

@moylop260 moylop260 merged commit 4042d42 into OCA:11.0 Feb 1, 2018
@astirpe astirpe deleted the 11_mig_account_invoice_supplier_ref_unique branch February 1, 2018 17:58
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.