Sale/Purchase/Invoice/Picking: Constraint Error-Order Reference must be unique per company

Bug #800100 reported by Meera Trambadia (OpenERP)
26
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
OpenERP R&D Addons Team 3
6.0
Confirmed
Undecided
Unassigned

Bug Description

1.Create a new db and install the multi-company module.
2.Change the user company to Shop1.
3.Create a Sale order and Save the record.

It gives the following error:-
IntegrityError: duplicate key value violates unique constraint "sale_order_name_uniq"

Related branches

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Meera,

As per I think sale order name field is a sequence field and not a read only field So end user can change.
Now if we trying to create two SO with different company then we can add the related unique prefix (eg: company name /code -sequence).

So the constraint will not block the end user for inserting two different company SO with the same name.

So currently I am setting this issue as an "Opinion" status for more discussion.

Thanks.

Changed in openobject-addons:
status: New → Opinion
summary: - Sale: Constraint Error-Order Reference must be unique
+ Sale: Constraint Error-Order Reference must be unique per company
Revision history for this message
Ferdinand (office-chricar) wrote : Re: Sale: Constraint Error-Order Reference must be unique per company

critical
this is still not fixed in trunk

Changed in openobject-addons:
status: Opinion → New
Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Ferdinand,

This issue has still remaining for discussion, currently I am not considering this as a bug because end user can change this filed 's value.

At other side in multi-company environment most probably the prifix of the sale order's ref are different. If both comapny have same prefix then it will confusing to find out specific record.

So you can create a new sequence with different prefix for another company then it will never create a problem.
Currently due to server problem if you give the higher sequence for child company it will never consider this only allowing a lower sequence for both comapny please check the lp:863221.

I am again setting this as an "Opinion" for more discussion.

@OpenERP Community Members : Would you please share your view on this.

Thanks.

Changed in openobject-addons:
status: New → Opinion
Revision history for this message
Ferdinand (office-chricar) wrote :

well - the prefix is defitively a good idea

... to be also implemented in the test data ;-)

Revision history for this message
Ferdinand (office-chricar) wrote :

have to correct myself

1) the demo data inserts SO lines, but does NOT adjust the sequences accordingly - hence error trying the demo

2) having different prefixes for multi company seems a rarely used praxis here.

we are running multi company for many years and all documents have the same prefix - the documents can be visually identified by the different companies document header.

and I wouldn't know what to put there as unique company identifier (res_company.id?)

and if we would have one it should be defined in res_company and be available as variable (%ci) in sequences

and it makes the number longer

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello DR Ferdinand,

Thanks for your reply and good explanation!

I am agree with your comment#5, that more then one company have a same prefix.
So I would like to suggest following suggestion for changing the constraint.

    _sql_constraints = [
        ('name_uniq', 'unique(name,company_id)', 'Order Reference must be unique per Company!'),
    ]

Thanks again!

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Low
status: Opinion → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Ferdinand (office-chricar) wrote :

please can you check for other tables (documents)
PO,INV, MO, PICK ......

Revision history for this message
DJ Patel (OpenERP) (mdi-openerp) wrote :

Hello Meera Trambadia,

Thanks for reporting. The solution for this bug is proposed in the branch : https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-800100-mdi/

with following Revision ID and Number.

Revision ID : <email address hidden>
Revision Number : 5506

Thanks and Regards,

Divyesh Makwana(MDI)

Changed in openobject-addons:
status: In Progress → Fix Committed
Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Divyesh,

I am agree with the Ferdinand 's comment #7, We need to improve MO and Picking also.

For invoice the invoice number is a read-only field and it will create automatically, So I suggest that would you please add new _sql_constraint for mrp and picking(Both object has company_id field).

We have set a same behaviour for most of the all applications so this need to be improve.

Thanks.

summary: - Sale: Constraint Error-Order Reference must be unique per company
+ Sale/Purchase/Invoice/Picking: Constraint Error-Order Reference must be
+ unique per company
Changed in openobject-addons:
milestone: none → 6.1
Revision history for this message
Ferdinand (office-chricar) wrote :

Manufactoring order ?

Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

Yes we will do it for MO too.

Revision history for this message
Purnendu Singh (OpenERP) (purnendu-singh) wrote :

Merged into addons at revision 5738

Changed in openobject-addons:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.