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

[10.0][MIG] : account_invoice_customer_ref_unique #257

Closed
wants to merge 8 commits into from

Conversation

misern2
Copy link

@misern2 misern2 commented Apr 14, 2017

USAGE

This module adds a insensitive constraint on the name Customer Reference
(name field): (partner_id, name) must be unique.

* Test coverage added
* Spanish translation
Travis Build Test
flake errors
flake modifications
@misern2 misern2 changed the title [10.0][MIG] : account_invoice_customer_ref_uniqe [10.0][MIG] : account_invoice_customer_ref_unique Apr 14, 2017
@AaronHForgeFlow AaronHForgeFlow mentioned this pull request Sep 26, 2017
34 tasks
Copy link
Contributor

@AaronHForgeFlow AaronHForgeFlow left a 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):
Copy link
Contributor

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

Copy link
Contributor

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

@misern2
Copy link
Author

misern2 commented Sep 30, 2017

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

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

Copy link
Contributor

@moylop260 moylop260 left a 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"
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this small change

@moylop260
Copy link
Contributor

...and create a hook to auto-fix all current wrong info breaking the constraint:
https://travis-ci.org/OCA/account-invoicing/jobs/281607395#L1407

@misern2 misern2 force-pushed the 10-invoice_customer_ref_unique branch from 4861ca5 to 32b506a Compare September 30, 2017 18:00
[FIX] minor travis build issues
[FIX] Test updated : Integrity Error
@misern2 misern2 force-pushed the 10-invoice_customer_ref_unique branch from 32b506a to aa66b51 Compare September 30, 2017 18:54
@misern2
Copy link
Author

misern2 commented Sep 30, 2017

@moylop260 I think it's all finshed. I also checked the travis log file and now there is not any error beta message.
Thanks.

Copy link
Contributor

@moylop260 moylop260 left a 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
Copy link
Contributor

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 @@
#
##############################################################################
Copy link
Contributor

Choose a reason for hiding this comment

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

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

missing newline


Configuration
=============

Copy link
Contributor

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 -*-
# #############################################################################
Copy link
Contributor

Choose a reason for hiding this comment

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

Short license

@adrienpeiffer adrienpeiffer added this to the 10.0 milestone Oct 2, 2017
def _compute_customer_ref_strip(self):
for invoice in self:
invoice_type = invoice.type
if invoice_type not in ['out_invoice', 'out_refund']:

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
@misern2
Copy link
Author

misern2 commented Oct 2, 2017

Changes requested.
The travis build on my branch was Ok and It fails on this PR in my last commit. Am I missing something ?

@pedrobaeza
Copy link
Member

Travis is red

@github-actions
Copy link

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.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 27, 2022
@github-actions github-actions bot closed this May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants