Skip to Content
Menu
This question has been flagged
3 Replies
1382 Views

I needed to add some fields (15 in total) to sale.order.form's order lines. I inherited the original form and added the additional fields, but after I did it, the Product, Description and Taxes (product_id, name and tax_id) fields dissappeared.

When creating a new Quotation/SO, the mentioned fields aren't visible, but the Add a product/section/note buttons can still be used.

If I add a product, by using the arrow keys after clicking Add a product, and then save the quotation, when I edit the quotation the three missing fields appear magically.

The same happenned when I tried to add the fields with Odoo Studio, so I thought that trying to code it myself would avoid the problem.

Why does this happen? How can I make the fields visible again when creating Quotations/SO, not only when editing them?


Edit: Here´s my code:


This is the XML where I added the fields:


<odoo>
  <data>
    <record model="ir.ui.view" id="sale_order_view_inherit">
      <field name="name">sale.order.view.inherit</field>
      <field name="model">sale.order</field>
      <field name="inherit_id" ref="sale.view_order_form"/>
      <field name="arch" type="xml">
          <xpath expr="/form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='price_unit']" position="after">
              <field name="list_price"/>
              <field name="vendor_discount" widget="percentage"/>
              <field name="vendor_discounted" widget="monetary"/>
              <field name="fob_total" widget="monetary"/>
              <field name="tariff" widget="percentage"/>
              <field name="tariff_cost" widget="monetary"/>
              <field name="total_tariff_cost" widget="monetary"/>
              <field name="cost" widget="monetary"/>
              <field name="admin_cost" widget="monetary"/>
              <field name="final_cost" widget="monetary"/>
              <field name="total_final_cost" widget="monetary"/>
              <field name="margin" widget="percentage"/>
              <field name="profit_margin" widget="monetary"/>
              <field name="profit" widget="monetary"/>
              <field name="sell_price" widget="monetary"/>
          </xpath>
      </field>
    </record>

The model code:


class SaleOrderLine(models.Model):
    _inherit = 'sale.order.line'
    list_price = fields.Float('List Price', compute='_compute_list_price', readonly=True, store=True)
    vendor_discount = fields.Float('Vendor Discount', store=True)
    
   #  ...

   #  More field declarations of the same kind

   #  ...
    
    @api.depends('product_id')
    def _compute_list_price(self):
        for line in self:
            line.list_price = line.product_id.standard_price    


   # ...
   # More compute functions
   # ...


   

Avatar
Discard

As imran told, please add the code along with the question for better understanding

Author

Okay, I just added the XML and a fragment of the model.

Best Answer

May  I see your written code for batter understanding. So i can help you in better way. This can be happen due to security groups too. Have you set security groups in security/security.xml file in your newly created module.

Regards:

MUHAMMAD Imran

Avatar
Discard
Author

There is no security.xml file. I used the scaffolding tool from odoo-bin to create the module, and I haven't modified anything in the security folder.

Anyways, here is the ir.model.access.csv file that is in the security folder.

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink

access_quote_fields_quote_fields,quote_fields.quote_fields,model_quote_fields_quote_fields,base.group_user,1,1,1,1

Watch this video i am sure this video help you to fix your problem.

https://www.youtube.com/watch?v=mzg3EGD_6Gw&t=783s.

Author

Okay. But, I don't think it's an access issue, because even if I don't see the Product header, I can still add the products. It looks more like there's no enough space.

Anyways, I'll watch the video, thanks.

Author

I watched the video, but I found nothing related to my problem.