You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.9 KiB

9 years ago
  1. # -*- encoding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Point Of Sale - Order Pricelist Change for Odoo
  5. # Copyright (C) 2014 GRAP (http://www.grap.coop)
  6. # @author Sylvain LE GAL (https://twitter.com/legalsylvain)
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU Affero General Public License as
  10. # published by the Free Software Foundation, either version 3 of the
  11. # License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU Affero General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Affero General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. ##############################################################################
  22. from openerp.models import Model
  23. from openerp import api, _
  24. class PosOrder(Model):
  25. _inherit = 'pos.order'
  26. @api.multi
  27. def action_recompute_pricelist(self):
  28. for po in self:
  29. for pol in po.lines:
  30. res = pol.onchange_product_id(
  31. po.pricelist_id.id, pol.product_id.id, qty=pol.qty,
  32. partner_id=po.partner_id.id)
  33. pol.write(res['value'])
  34. @api.onchange('pricelist_id')
  35. def onchange_pricelist_id(self):
  36. if not self.pricelist_id or not self.lines:
  37. return {}
  38. warning = {
  39. 'title': _('Pricelist Warning!'),
  40. 'message': _(
  41. """If you change the pricelist of this order,"""
  42. """ prices of existing order lines will not be updated."""
  43. """ Please click on the 'Recompute With Pricelist'.""")
  44. }
  45. return {'warning': warning}