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.

28 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. from openerp import models, api, fields
  3. class PurchaseOrder(models.Model):
  4. _inherit = 'purchase.order'
  5. manual_date_planned = fields.Datetime(string='Scheduled Date', required=True)
  6. @api.onchange('order_line', 'order_line.date_planned')
  7. def _on_change_manual_date_planned(self):
  8. """
  9. Since we don't see the date planned on the line anymore
  10. give an idea of the user by setting the first date planned of the lines
  11. """
  12. for line in self.order_line:
  13. if line.date_planned and not self.manual_date_planned:
  14. self.manual_date_planned = line.date_planned
  15. break;
  16. @api.multi
  17. def button_confirm(self):
  18. """
  19. Since we hide the button to set the date planned on all line and we
  20. hide them, we call the method to set the date planned on the line at the confirmation
  21. """
  22. self.ensure_one()
  23. self.with_context(date_planned=self.manual_date_planned).action_set_date_planned()
  24. return super(PurchaseOrder, self).button_confirm()