sale_order.py 648 B

12345678910111213141516171819202122232425
  1. # -*- coding: utf-8 -*-
  2. from openerp import api, fields, models
  3. from openerp.exceptions import except_orm
  4. class SaleOrderInsert(models.Model):
  5. _inherit = 'sale.order'
  6. @api.model
  7. def sale_insert_lines_by_eiru_original(self, values):
  8. sale_lines_eiru = self.env['sale.order.line']
  9. lines = sale_lines_eiru.search([
  10. ('order_id', '=', values['id']),
  11. ('product_id', '=', values['product_id']),
  12. ])
  13. if len(lines) == 0:
  14. lines = {
  15. 'order_id' : values['id'],
  16. 'product_id': values['product_id'],
  17. }
  18. sale_lines_eiru.create(lines);
  19. if len(lines) == 1:
  20. lines.write({
  21. 'product_uom_qty': lines.product_uom_qty + 1,
  22. })