Comment 11 for bug 599204

Revision history for this message
vrsb (shipilov555) wrote :

Here it is:
<?xml version="1.0"?>
<form string="Sale Shop">
                    <field name="name" select="1"/>
                    <field name="warehouse_id" required="1" select="1"/>
                    <separator colspan="4" string="Accounting"/>
                    <field name="payment_default_id"/>
                    <field domain="[('type','=','sale')]" name="pricelist_id" select="1"/>
                    <field name="project_id" select="1"/>
                    <separator colspan="4" string="Payment accounts"/>
                    <field colspan="4" name="payment_account_id" nolabel="1"/>
                </form>

>We have tried to generate the error and the only way we could do it was to change the view of sale.shop and set the warehouse_id field to be 'not required'.

It is not the only way. If you went to Stock management\Configuration\Warehouses and just remove the warehouse relate to the shop, he field under discussion of shop object become clear. The are no ORM database constraints that disable to do such a thing. «required="1"» in xml acts only when a users tries to save particular form, with no database relations checking.
Maybe in my case somebody removed id while testing and then added back.

So, if you are so so much interested in making this situation impossible, you should add a database constraint in field declaration in sale.py:
warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
insread
warehouse_id': fields.many2one('stock.warehouse', 'Warehouse'),