Odoo Help

0

0
3 Answers
0
Maulik Shah
22/08/18, 03:04

overriding the onchange_product_id() will solve problem:

class purchase_ordr_line(models.Model):

_inherit = "purchase.order.line"


@api.multi
def onchange_product_id(self, pricelist_id, product_id, qty, uom_id,
        partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
        name=False, price_unit=False, state='draft'):
        dic_res = super(purchase_ordr_line, self).onchange_product_id(pricelist_id, product_id, qty, uom_id,partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
        name=False, price_unit=False, state='draft')
       #Following the custom code:
       dic_value = dic_res['value']
       dic_value['new_field_to_update'] = new_value
       return dic_res


0
Ilusoria
09/05/17, 10:19

I'm not sure if I understood the question, but you can edit a object in inline mode using the editable="top" attribute in the tree tag from xml view document.

If you want to use one field from one model from other use related attribute in your python file.

The python file:

For get the fields from one model to other model to use it you can use the "related" attribute on the field variable declaration.

order_line_id = fields.One2many(purchase.order.line, "id_of_order_from_order_line_module")
order_line_product = fields.Many2one(related="order_line_id .product_id")
order_line_description = fields.Text(related="order_line_id .description")

now you can use the fields: description and product from order line into order model.

but if that you need is just edit in the tree view just modify the xml tree view.

the xml file:


<field name="order_line_id">
                  <tree string="Order Line" editable="top">
                    <field name="product_id"/>
                    <field name="descrition"/>
                  </tree>
</field>


If you are editing in the order view, the method will trigger the onchange from order model for the context.

If you want to access the attribute, you can use the dot notation


@api.onchange('product_id')   
     def on_change_product(self):
          _logger.log("on_change_  {}",self.product_id)
           _logger.log("on_change_  {}",self.product_id.description)
0
Megha_SerpentCS
28/08/18, 05:43

Salim Rahal,

You can do with the JS by doing onclick.

Thank You.

Ask a Question
Writer
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now