Odoo Ayuda


3 Respuestas
Maulik Shah India
22/8/18 3:04

overriding the onchange_product_id() will solve problem:

class purchase_ordr_line(models.Model):

_inherit = "purchase.order.line"

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

Ilusoria Colombia
9/5/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"/>

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

     def on_change_product(self):
          _logger.log("on_change_  {}",self.product_id)
           _logger.log("on_change_  {}",self.product_id.description)
Megha_SerpentCS India
28/8/18 5:43

Salim Rahal,

You can do with the JS by doing onclick.

Thank You.

Realizar una pregunta
Keep Informed
1 seguidor(es)
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.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now