Skip to content

Commit

Permalink
[FIX][9.0][backport]A user can only select the operating units that h…
Browse files Browse the repository at this point in the history
…e is allowed (#60)

* [UPT]A user can only select the operating units that he is allowed

* [FIX] Purchase OU. The check is done in the PO line
  • Loading branch information
AaronHForgeFlow authored and JordiBForgeFlow committed Feb 10, 2017
1 parent 90f1dc6 commit 64d97d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
12 changes: 12 additions & 0 deletions operating_unit/security/operating_unit_security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
</record>

<record id="ir_rule_operating_unit_allowed_operating_units"
model="ir.rule">
<field name="model_id" ref="model_operating_unit"/>
<field name="domain_force">[('id','in',[g.id for g in user.operating_unit_ids])]</field>
<field name="name">Allowed operating units</field>
<field name="global" eval="True"/>
<field eval="0" name="perm_unlink"/>
<field eval="0" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="0" name="perm_create"/>
</record>

</data>
</openerp>
10 changes: 0 additions & 10 deletions purchase_operating_unit/models/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,6 @@ def _prepare_picking(self):
picking_vals['operating_unit_id'] = self.operating_unit_id.id
return picking_vals

@api.constrains('invoice_ids', 'operating_unit_id')
def _check_invoice_ou(self):
for po in self:
for invoice in po.invoice_ids:
if invoice.operating_unit_id != po.operating_unit_id:
raise ValidationError(
_('The operating unit of the purchase order must '
'be the same as in the associated invoices.')
)


class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'
Expand Down

0 comments on commit 64d97d2

Please sign in to comment.