← Back to team overview

openerp-india team mailing list archive

[Bug 1000556] Re: field margin doesn't work properly when sale_layout is installed

 

Sale_layout is not available on trunk any more. So this issue doesn't
effect it.

Thanks!

** Summary changed:

- field margin doesn't work properly when sale_layout is installed
+ [6.1]field margin doesn't work properly when sale_layout is installed

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/1000556

Title:
  [6.1]field margin doesn't work properly when sale_layout is installed

Status in OpenERP Addons (modules):
  Fix Committed

Bug description:
  margin field doesn't work properly when we have sale_margin and
  sale_layout both installed in 6.1 and trunk.

  Simple steps to reproduce:
  1. install sale_margin and sale_layout
  2. go to sales order and create one sale item
  3. check margin field on sale order form view

  Problem:
  Further investigation make understand that it is due to module sale_layout,
  order_line of sale.order is replaces by abstract_line_ids(created in sale_layout by inheriting sale.order) in view so
  sale.order form view will not have order_line, and as per margin field's store functionality,
  'margin': fields.function(_product_margin, string='Margin', help="It gives profitability by calculating the difference between the Unit Price and Cost Price.", store={
                  'sale.order.line': (_get_order, ['margin'], 20),
                  'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 20),
                  }),

  function will only be executed when order_line changes and we no more
  have order_line when we install sale_layout.

  Solution should be something like this, to put abstract_line_ids in
  store,

  'margin': fields.function(_product_margin, string='Margin', help="It gives profitability by calculating the difference between the Unit Price and Cost Price.", store={
                  'sale.order.line': (_get_order, ['margin'], 20),
                  'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line', 'abstract_line_ids'], 20),
                  }),

  But still abstract_line_ids comes from sale_layout so we can not
  directly put it in margin field(module sale_margin).

  A module which has dependency of both sale_layout and sale_margin, which inherit sale.order and do above changes
  would solve the issue.(I already did) If there is another way to fix this issue, It would really appreciated.

  Note that we can not create new module or do major schema level changes in stable, so I will be glad if this will be fixed
  in trunk.

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/1000556/+subscriptions


References