Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
2344 Vizualizări

<record id="hr_timesheet_line_form2" model="ir.ui.view">			
    <field name="name">account.analytic.line.form2</field>
    <field name="model">account.analytic.line</field>
    <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_form"/>
    <field name="context">{'check_remaining': True}</field>
    <field name="arch" type="xml">
    <xpath expr="//field[@name='unit_amount']" position="attributes">
    <attribute name="context">{'check_remaining': True}</attribute>
    </xpath> ...
// in my code
class AccountAnalyticLineExt(models.Model):
_inherit = 'account.analytic.line'
    ...

    def _timesheet_preprocess(self, vals): 
        vals = super(AccountAnalyticLineExt, self)._timesheet_preprocess(vals);       
        remaining = self.env.context.get('check_remaining', False) // always False

I try 2 times to set the context with check_remaining to True, because i want to check if the call came from my own (inherited) view, but it is ALWAYS False. Any Idea? My Odoo is odoo 11. Thanks
Imagine profil
Abandonează
Cel mai bun răspuns

context is set in ir.actions.act_window rather than ir.ui.view, you may want to try to set context in current action

Imagine profil
Abandonează
Autor

Thanks a lot!

Autor Cel mai bun răspuns

Thanks DuongLong this is the solution. It has to be added to action:

<record id="hr_timesheet.act_hr_timesheet_line" model="ir.actions.act_window">

<field name="context">{"search_default_week":1, "check_remaining": True}</field>

</record>
Imagine profil
Abandonează