-
-
Notifications
You must be signed in to change notification settings - Fork 689
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
[10.0][MIG] : account_invoice_customer_ref_unique #257
Conversation
* Test coverage added * Spanish translation
Travis Build Test
flake errors
flake modifications
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.
👍
It'll be great a pre-install hook to prevent this constraint to be triggered when installing.
invoice = self.browse(cr, uid, i_id, context=context) | ||
@api.multi | ||
@api.constrains('name') | ||
def _check_unique_name_insensitive(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.
In order to increase the performance is faster use a sql constraint based on computed fields with store=True
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.
check the following example where is 4x faster than a python constraint using too many invoices https://github.com/Vauxoo/addons-vauxoo/blob/8.0/supplier_invoice_number_unique/model/account_invoice.py
@moylop260 Thanks for your revision. I pushed a new commit with the SQL Constraints |
invoice.customer_ref_strip = invoice.name.lower() | ||
_sql_constraints = [ | ||
('unique_customer_ref_strip', 'UNIQUE(' | ||
'customer_ref_strip, company_id, partner_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.
s/partner_id/commercial_partner_id/g` in order to supports the case where other address is used for the same partner
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.
LGTM just small changes.
And check our beta message of the lint build:
https://travis-ci.org/OCA/account-invoicing/jobs/281607391#L743
************* Module account_invoice_customer_ref_unique
account_invoice_customer_ref_unique/README.rst:32: [E7901(rst-syntax-error), ] Unexpected possible title overline or transition.|Treating it as ordinary text because it's so short.
account_invoice_customer_ref_unique/README.rst:1: [W7908(missing-newline-extrafiles), ] Missing newline
************* Module account_invoice_customer_ref_unique.__manifest__
account_invoice_customer_ref_unique/__manifest__.py:1: [C8201(no-utf8-coding-comment), ] No UTF-8 coding comment found: Use `# coding: utf-8` or `# -*- coding: utf-8 -*-`
account_invoice_customer_ref_unique/__manifest__.py:23: [C8103(manifest-deprecated-key), ] Deprecated key "description" in manifest file
************* Module account_invoice_customer_ref_unique.models.account_invoice
account_invoice_customer_ref_unique/models/account_invoice.py:1: [C8201(no-utf8-coding-comment), ] No UTF-8 coding comment found: Use `# coding: utf-8` or `# -*- coding: utf-8 -*-`
.travis.yml
Outdated
@@ -1,7 +1,7 @@ | |||
language: python | |||
|
|||
python: | |||
- "2.7" | |||
- "2.7" |
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.
remove this small change
...and create a hook to auto-fix all current wrong info breaking the constraint: |
4861ca5
to
32b506a
Compare
[FIX] minor travis build issues [FIX] Test updated : Integrity Error
32b506a
to
aa66b51
Compare
@moylop260 I think it's all finshed. I also checked the travis log file and now there is not any error beta 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.
Sorry I didn't see this before...
Thanks for your great work!
@@ -20,4 +20,5 @@ | |||
# | |||
############################################################################## | |||
|
|||
from . import account_invoice | |||
|
|||
from . import models |
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.
Missing newline
@@ -20,4 +20,5 @@ | |||
# | |||
############################################################################## |
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.
Use shortest license like as template module:
https://github.com/OCA/maintainer-tools/blob/master/template/module/models/model_name.py#L2
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
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.
missing newline
|
||
Configuration | ||
============= | ||
|
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.
Remove unused sections
@@ -0,0 +1,46 @@ | |||
# -*- coding: utf-8 -*- | |||
# ############################################################################# |
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.
Short license
def _compute_customer_ref_strip(self): | ||
for invoice in self: | ||
invoice_type = invoice.type | ||
if invoice_type not in ['out_invoice', 'out_refund']: |
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.
maybe we can remove the previous line as the invoice_type variable is only used once in the if statement
shorter license updated Removed unused sections in README removed invoice_type variable in account_invoice.py
Changes requested. |
Travis is red |
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
USAGE
This module adds a insensitive constraint on the name Customer Reference
(name field): (partner_id, name) must be unique.