<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <record id="except_unit_amount_over_eight_hours" model="exception.rule">
        <field name="name">Unit amount exceeds 8 hrs</field>
        <field name="description">Unit amount over 8 hrs</field>
        <field name="sequence">50</field>
        <field name="model">account.analytic.line</field>
        <field name="code">failed = self._context.get("newVals", {}).get("validated", False) == True and self.unit_amount > 8</field>
        <field name="active" eval="True"/>
    </record>

    <record id="except_unit_amount_over_ordered_quantity" model="exception.rule">
        <field name="name">SO delivered qty plus unit amount exceeds ordered qty</field>
        <field name="description">SO delivered qty plus unit amount exceeds ordered qty</field>
        <field name="sequence">50</field>
        <field name="model">account.analytic.line</field>
        <field name="code">failed = self._context.get("newVals", {}).get("validated", False) == True and (self.so_line.product_template_id.service_policy == 'ordered_timesheet' and self.so_line.qty_delivered + self.unit_amount > self.so_line.product_uom_qty)</field>
        <field name="active" eval="True"/>
    </record>

</odoo>
