When I looking at the lot_type = public and click on create or make my own button - The Context lot_type="public" doesn't get passed on to the new form so my hide and show fields are not working .
Here is the code - what am I missing ?
View
<odoo>
<data>
<record id="lot_product_form" model="ir.ui.view">
<field name="name">product.template.common.form.inherit</field>
<field name="model">product.template</field>
<field name="view_mode">form</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='general_information']" position="after">
<page string="Lotting" name="conslotter">
<field name="context" />
<field name="lot_type">context.get('lot_type', False)</field>
<label for="description">Description</label>
<field name="description" widget="html"/>
<group string="Information">
<group>
<field name="larglot" attrs="{'invisible':[('lot_type','=','Public')]}"/>
<field name="consignor" attrs="{'invisible':[('lot_type','=','Mail')]}" />
<field name="cover" attrs="{'invisible':[('lot_type','=','Mail')]}" />
<field name="timesrun" attrs="{'invisible':[('lot_type','=','Public')]}"/>
<field name="symbol_id" widget="many2many_checkboxes"/>
</group>
<group>
<field name="book" attrs="{'invisible':[('lot_type','=','Mail')]}"/>
<field name="lotted_by"/>
</group>
</group>
<group string="Scott/Cat#">
<field name="scott_num"/>
<field name="scottpre"/>
<field name="scottsub"/>
<field name="scottsort"/>
</group>
<group string="Valuation">
<field name="value" widget="monetary"/>
<field name="value_type"/>
<field name="reserve" widget="monetary" help="Minimum we need to sell for" />
<field name="retail" widget="monetary" help="Minimum we need to sell for" attrs="{'invisible':[('lot_type','=','Mail')]}"/>
<field name="expect" widget="monetary" help="Expected amt for item " attrs="{'invisible':[('lot_type','=','Mail')]}"/>
<field name="opening_bid" widget="monetary" help="Minimum we need to sell for" attrs="{'invisible':[('lot_type','=','Public')]}"/>
<field name="reserve" widget="monetary" help="Reserve" />
<field name="minimum" widget="monetary" help="Minimum we need to sell for" attrs="{'invisible':[('lot_type','=','Public')]}"/>
<field name="expect" widget="monetary" help="Expected amt for item " attrs="{'invisible':[('lot_type','=','Public')]}"/>
</group>
<group string="Lot Notes">
<field name="notes"/>
</group>
<group string="Misc">
<field name="location"/>
<field name="qtyoh" help="Quantity on Hand" attrs="{'invisible':[('lot_type','=','Public')]}" />
<field name="lot_type"/>
<field name="color" widget="lot_color"/>
</group>
</page>
<page string="Auctions" name="auctions">
<field name="auction_id"/>
</page>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="lots_product_tree">
<field name="name">lots.product.tree.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_tree_view"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree position="replace">
<tree create="true" edit="true">
<button string="Create New Public Lot" class="oe_create_button" type="object" name="new_public" context="{
'lot_type': 'Public'}" attrs="{'lot_type':'Public'}" />
<field name="name"/><field name="lot_type" />
<field name="context" />
</tree>
</tree>
</field>
<!--
</tree>
</field>
<xpath expr="/tree/field[@name='name']" position="after">
<field name="lot_type" />
<field name="context" />
</xpath>
</field>
-->
</record>
<record id="lots_product_search_view" model="ir.ui.view" >
<field name="name">lots.product.search.view</field>
<field name="model">product.template</field>
<field name="arch" type="xml">
<search string="Search Lot Types">
<filter string="Public" name="lot_type_public" domain="[('lot_type','=','Public')]" help="Show only Public Lots" />
<filter string="Mail" name="lot_type_mail" domain="[('lot_type','=','Mail')]" help="Show only Mail Lots" />
</search>
</field>
</record>
</data>
</odoo>
My Actions
<record model="ir.actions.act_window" id="action_public_lots">
<field name="name">Public Lots</field>
<field name="res_model">product.template</field>
<field name="view_mode">kanban,tree,form</field>
<field name="domain">[('lot_type','=','Public')]</field>
<field name="context">{'lot_type':'Public'}</field>
</record>
<record model="ir.actions.act_window" id="action_public_form">
<field name="name">Public Lots</field>
<field name="res_model">product.template</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="lot_type">Public</field>
<field name="context">{'lot_type':'Public'}</field>
</record>
<record model="ir.actions.act_window" id="action_mail_lots">
<field name="name">Mail Lots</field>
<field name="res_model">product.template</field>
<field name="view_mode">kanban,tree,form</field>
<field name="domain">[('lot_type','=','Mail')]</field>
<field name="context">{'lot_type':'Mail'}</field>
</record>
</data>
</odoo>
and my Model
class gjlcrm_products(models.Model):
def _get_context(self):
self.context = dict(self.env.context)
def new_public(self, cr, uid=None, vals=None, context=None):
context = {'lot_type': 'Public'}
return {'name': ('New Public Lot'), 'view_type': 'form', 'view_mode': 'form', 'res_model': 'product.template','view_id': False, 'type': 'ir.actions.act_window', 'target': 'self', 'context': context}
_name = 'product.template'
_inherit = ['product.template', 'gjlcrm.public_lots', 'gjlcrm.mail_lots']
context = fields.Char(string='Context', compute='_get_context')
Note that I not only have tried with Model Method but also with just straight up xml that points to the action with the context in the field but both do not seem to pass lot_type to my form . What am I missing ?
Thanks for your help ahead of time
If I even try to do this -
view_id = self.env.ref("gjlcrm.lot_public_form").id
what happens is that I get error that says
ValueError: External ID not found in the system: gjlcrm.lot_public_form
and if I don't put gjlcrm it splits module name but for some reason my odoo says gjlcrm isn't installed but I have installable true in my manifest . why doesn't this work - could be reason nothing works the way it should ?