Browse Source

Merge pull request #29 from beescoop/9.0-houssine78-clean-remove-order-line

9.0 houssine78 clean remove order line
pull/27/merge
Houssine BAKKALI 7 years ago
committed by GitHub
parent
commit
73e637fced
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      beesdoo_pos_remove_0_qty/__init__.py
  2. 4
      beesdoo_pos_remove_0_qty/__openerp__.py
  3. 2
      beesdoo_pos_remove_0_qty/models/__init__.py
  4. 19
      beesdoo_pos_remove_0_qty/models/pos_order.py
  5. 25
      beesdoo_pos_remove_0_qty/models/pos_order_line.py

1
beesdoo_pos_remove_0_qty/__init__.py

@ -1,2 +1,3 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from . import models from . import models

4
beesdoo_pos_remove_0_qty/__openerp__.py

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2016-Today: La Louve (<http://www.lalouve.net/>)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# Copyright (C) 2016-Today: BEES coop (<http://www.bees-coop.be/>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -9,7 +8,6 @@
'version': '9.0.1.0.0', 'version': '9.0.1.0.0',
'category': 'Custom', 'category': 'Custom',
'summary': 'Remove pos order line with quantity set to 0', 'summary': 'Remove pos order line with quantity set to 0',
'author': 'La Louve - Sylvain LE GAL',
'author': 'BEES coop - Houssine BAKKALI', 'author': 'BEES coop - Houssine BAKKALI',
'website': 'http://www.bees-coop.be', 'website': 'http://www.bees-coop.be',
'depends': [ 'depends': [

2
beesdoo_pos_remove_0_qty/models/__init__.py

@ -1,2 +1,2 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from . import pos_order_line
from . import pos_order

19
beesdoo_pos_remove_0_qty/models/pos_order.py

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import api, models
class PosOrder(models.Model):
_inherit = 'pos.order'
@api.model
def _process_order(self, order):
print order
print order['lines']
lines = order['lines']
order['lines'] = [l for l in lines if l[2]['qty'] !=0]
print order['lines']
print order
return super(PosOrder, self)._process_order(order)

25
beesdoo_pos_remove_0_qty/models/pos_order_line.py

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2016-Today: La Louve (<http://www.lalouve.net/>)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# Julien Weste (julien.weste@akretion.com.br)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import api, models
class PosOrderLine(models.Model):
_inherit = 'pos.order.line'
@api.multi
def write(self, vals):
if 'qty' in vals.keys() and vals['qty'] == 0:
self.unlink()
else:
super(PosOrderLine, self).write(vals)
@api.model
def create(self, vals):
pol = super(PosOrderLine, self).create(vals)
if pol.qty == 0:
pol.unlink()
return pol
Loading…
Cancel
Save