From f0b124d52dc24d9175dfa030b6c8608151b92479 Mon Sep 17 00:00:00 2001 From: "sbh (Open ERP)" Date: Fri, 11 Jun 2010 11:32:15 +0530 Subject: [PATCH 1/3] [Fix] Point_of_sale:Fix the name of rule group bzr revid: sbh@tinyerp.com-20100611060215-zdkvnoqf1t2epbof --- addons/point_of_sale/pos.py | 6 +++--- addons/point_of_sale/posrule_data.xml | 20 +++++++++++++------- addons/point_of_sale/statement_data.xml | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/addons/point_of_sale/pos.py b/addons/point_of_sale/pos.py index 5d4df5a5f10..0ec31cb88fe 100644 --- a/addons/point_of_sale/pos.py +++ b/addons/point_of_sale/pos.py @@ -193,7 +193,7 @@ class pos_order(osv.osv): res[order.id]['amount_tax']) else: res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), - tax_obj.compute(cr, uid, line.product_id.taxes_id, + tax_obj.compute_all(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty), res[order.id]['amount_tax']) @@ -789,7 +789,7 @@ class pos_order(osv.osv): tax_amount = 0 taxes = [t for t in line.product_id.taxes_id] if order.price_type=='tax_excluded': - computed_taxes = account_tax_obj.compute( + computed_taxes = account_tax_objcompute_all( cr, uid, taxes, line.price_unit, line.qty) else: computed_taxes = account_tax_obj.compute_inv( @@ -1058,7 +1058,7 @@ class pos_order_line(osv.osv): for line in self.browse(cr, uid, ids): tax_amount = 0.0 taxes = [t for t in line.product_id.taxes_id] - computed_taxes = account_tax_obj.compute(cr, uid, taxes, line.price_unit, line.qty) + computed_taxes = account_tax_objcompute_all(cr, uid, taxes, line.price_unit, line.qty) for tax in computed_taxes: tax_amount += tax['amount'] price = self.price_by_product(cr, uid, ids, line.order_id.pricelist_id.id, line.product_id.id, line.qty, line.order_id.partner_id.id) diff --git a/addons/point_of_sale/posrule_data.xml b/addons/point_of_sale/posrule_data.xml index 905e78e6e7a..be1b3d0a802 100644 --- a/addons/point_of_sale/posrule_data.xml +++ b/addons/point_of_sale/posrule_data.xml @@ -2,6 +2,12 @@ + + point + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + @@ -63,12 +69,12 @@ - - - - - ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] - + + + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + @@ -98,7 +104,7 @@ ref('procurement.menu_mrp_procurement_action3'), ref('point_of_sale.menu_point_root')])]" name="menu_access"/> - + diff --git a/addons/point_of_sale/statement_data.xml b/addons/point_of_sale/statement_data.xml index 5172e0e70d4..a1f920c5c43 100644 --- a/addons/point_of_sale/statement_data.xml +++ b/addons/point_of_sale/statement_data.xml @@ -34,7 +34,7 @@ - + From ca9b03d3211ca34dd280d5c9da78c25cad2d59e7 Mon Sep 17 00:00:00 2001 From: "sbh (Open ERP)" Date: Fri, 11 Jun 2010 18:16:55 +0530 Subject: [PATCH 2/3] [IMP] point_of_sale: chagned name of method and put the data file in comment bzr revid: sbh@tinyerp.com-20100611124655-n8ksbqwyk13gsr81 --- addons/point_of_sale/__openerp__.py | 6 +++--- addons/point_of_sale/pos.py | 11 ++++------- addons/point_of_sale/test/pos_test.yml | 9 +++++++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/addons/point_of_sale/__openerp__.py b/addons/point_of_sale/__openerp__.py index 27707bcf0e0..b83834d0677 100644 --- a/addons/point_of_sale/__openerp__.py +++ b/addons/point_of_sale/__openerp__.py @@ -67,14 +67,14 @@ Main features : # 'pos_wizard.xml', 'pos_view.xml', 'pos_sequence.xml', - 'posrule_data.xml', + #'posrule_data.xml', 'pos_data.xml', 'pos_workflow.xml', 'statement_view.xml', 'statement_report.xml', - 'statement_data.xml', + #'statement_data.xml', ], - 'demo_xml': ['pos_demo.xml','singer_statement_demo.xml','multi_company_stock_data.xml'], + 'demo_xml': ['pos_demo.xml','singer_statement_demo.xml','multi_company_stock_data.xml',], 'test':['test/pos_test.yml',], 'installable': True, } diff --git a/addons/point_of_sale/pos.py b/addons/point_of_sale/pos.py index 0ec31cb88fe..d31706e1b0e 100644 --- a/addons/point_of_sale/pos.py +++ b/addons/point_of_sale/pos.py @@ -192,11 +192,10 @@ class pos_order(osv.osv): (1-(line.discount or 0.0)/100.0), line.qty), res[order.id]['amount_tax']) else: - res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), - tax_obj.compute_all(cr, uid, line.product_id.taxes_id, + res[order.id]['amount_tax'] = tax_obj.compute_all(cr, uid, line.product_id.taxes_id, line.price_unit * \ - (1-(line.discount or 0.0)/100.0), line.qty), - res[order.id]['amount_tax']) + (1-(line.discount or 0.0)/100.0), line.qty)['total_included'] + return res @@ -1058,9 +1057,7 @@ class pos_order_line(osv.osv): for line in self.browse(cr, uid, ids): tax_amount = 0.0 taxes = [t for t in line.product_id.taxes_id] - computed_taxes = account_tax_objcompute_all(cr, uid, taxes, line.price_unit, line.qty) - for tax in computed_taxes: - tax_amount += tax['amount'] + tax_amount = account_tax_obj.compute_all(cr, uid, taxes, line.price_unit, line.qty)['total_included'] price = self.price_by_product(cr, uid, ids, line.order_id.pricelist_id.id, line.product_id.id, line.qty, line.order_id.partner_id.id) if line.discount!=0.0: res[line.id] = line.price_unit * line.qty * (1 - (line.discount or 0.0) / 100.0) diff --git a/addons/point_of_sale/test/pos_test.yml b/addons/point_of_sale/test/pos_test.yml index a96a792c711..3019b49144d 100644 --- a/addons/point_of_sale/test/pos_test.yml +++ b/addons/point_of_sale/test/pos_test.yml @@ -119,7 +119,7 @@ I create Sales Account. - !record {model: account.account, id: account_account_sales0}: - code: S + code: Sale company_id: base.main_company currency_mode: current name: Sales @@ -473,4 +473,9 @@ self.action_confirm(cr, uid, [ref("pos_confirm_0")], {"lang": "en_US", "active_model": "pos.order", "active_ids": [ref("pos_order_pos0")], "tz": False, "active_id": ref("pos_order_pos0"), }) - +- + I check order state is done. +- + !python {model: pos.order}: | + order=self.browse(cr,uid,ref("pos_order_pos0")) + assert(order.state=='done'), "Order is not done" From dbf6ad6defdf70776a7e771d2b057a962eaf540c Mon Sep 17 00:00:00 2001 From: "sbh (Open ERP)" Date: Fri, 11 Jun 2010 18:33:03 +0530 Subject: [PATCH 3/3] [IMP] point_of_sale: Improve the code bzr revid: sbh@tinyerp.com-20100611130303-hc0hjszkh3lecoxl --- addons/point_of_sale/pos.py | 60 ++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/addons/point_of_sale/pos.py b/addons/point_of_sale/pos.py index d31706e1b0e..1e67f7872df 100644 --- a/addons/point_of_sale/pos.py +++ b/addons/point_of_sale/pos.py @@ -65,7 +65,7 @@ class pos_order(osv.osv): _order = "date_order desc" - def unlink(self, cr, uid, ids, context={}): + def unlink(self, cr, uid, ids, context=None): for rec in self.browse(cr, uid, ids, context=context): for rec_statement in rec.statement_ids: @@ -73,7 +73,7 @@ class pos_order(osv.osv): raise osv.except_osv(_('Invalid action !'), _('Cannot delete a point of sale which is closed or contains confirmed cashboxes!')) return super(pos_order, self).unlink(cr, uid, ids, context=context) - def onchange_partner_pricelist(self, cr, uid, ids, part, context={}): + def onchange_partner_pricelist(self, cr, uid, ids, part, context=None): """ Changed price list on_change of partner_id""" @@ -82,7 +82,7 @@ class pos_order(osv.osv): pricelist = self.pool.get('res.partner').browse(cr, uid, part).property_product_pricelist.id return {'value':{'pricelist_id': pricelist}} - def _amount_total(self, cr, uid, ids, field_name, arg, context): + def _amount_total(self, cr, uid, ids, field_name, arg, context=None): """ Calculates amount_tax of order line @param field_names: Names of fields. @@ -224,7 +224,7 @@ class pos_order(osv.osv): return res[0] else: return False - def copy(self, cr, uid, id, default=None, context={}): + def copy(self, cr, uid, id, default=None, context=None): if not default: default = {} @@ -333,7 +333,7 @@ class pos_order(osv.osv): else: return False - def _journal_default(self, cr, uid, context={}): + def _journal_default(self, cr, uid, context=None): """ To get default pricelist for the order" @param name: Names of fields. @@ -364,7 +364,7 @@ class pos_order(osv.osv): } - def test_order_lines(self, cr, uid, order, context={}): + def test_order_lines(self, cr, uid, order, context=None): """ Test order line is created or not for the order " @param name: Names of fields. @@ -377,7 +377,7 @@ class pos_order(osv.osv): wf_service.trg_validate(uid, 'pos.order', order.id, 'paid', cr) return True - def dummy_button(self, cr, uid, order, context={}): + def dummy_button(self, cr, uid, order, context=None): return True def test_paid(self, cr, uid, ids, context=None): @@ -457,11 +457,13 @@ class pos_order(osv.osv): # delete it in the new picking: line.unlink(context=context) - def create_picking(self, cr, uid, ids, context={}): + def create_picking(self, cr, uid, ids, context=None): """Create a picking for each order and validate it.""" picking_obj = self.pool.get('stock.picking') + property_obj=self.pool.get("ir.property") + move_obj=self.pool.get('stock.move') pick_name=self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out') orders = self.browse(cr, uid, ids, context) for order in orders: @@ -494,8 +496,8 @@ class pos_order(osv.osv): for line in order.lines: if line.product_id and line.product_id.type=='service': continue - prop_ids = self.pool.get("ir.property").search(cr, uid, [('name', '=', 'property_stock_customer')]) - val = self.pool.get("ir.property").browse(cr, uid, prop_ids[0]).value_reference + prop_ids = property_obj.search(cr, uid, [('name', '=', 'property_stock_customer')]) + val = property_obj.browse(cr, uid, prop_ids[0]).value_reference cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order.shop_id.warehouse_id.id)) res=cr.fetchone() location_id=res and res[0] or None @@ -504,7 +506,7 @@ class pos_order(osv.osv): if line.qty < 0: location_id, stock_dest_id = stock_dest_id, location_id - self.pool.get('stock.move').create(cr, uid, { + move_obj.create(cr, uid, { 'name': 'Stock move (POS %d)' % (order.id, ), 'product_uom': line.product_id.uom_id.id, 'product_uos': line.product_id.uom_id.id, @@ -582,7 +584,7 @@ class pos_order(osv.osv): @return: True """ self.write(cr, uid, ids, {'state': 'cancel'}) - self.cancel_picking(cr, uid, ids, context={}) + self.cancel_picking(cr, uid, ids, context=None) return True def add_payment(self, cr, uid, order_id, data, context=None): @@ -590,8 +592,10 @@ class pos_order(osv.osv): """Create a new payment for the order""" res_obj = self.pool.get('res.company') + statement_obj= self.pool.get('account.bank.statement') statementl_obj = self.pool.get('account.bank.statement.line') prod_obj = self.pool.get('product.product') + property_obj=self.pool.get('ir.property') flag='' curr_c=self.pool.get('res.users').browse(cr, uid, uid).company_id curr_company=curr_c.id @@ -608,7 +612,7 @@ class pos_order(osv.osv): args['date'] = data['payment_date'] if 'payment_name' in data.keys(): args['name'] = data['payment_name'] + ' ' +order.name - account_def = self.pool.get('ir.property').get(cr, uid, 'property_account_receivable', 'res.partner', context=context) + account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context) args['account_id'] = order.partner_id and order.partner_id.property_account_receivable and order.partner_id.property_account_receivable.id or account_def.id or curr_c.account_receivable.id if data.get('is_acc',False): args['is_acc']=data['is_acc'] @@ -618,7 +622,6 @@ class pos_order(osv.osv): args['partner_id'] = order.partner_id and order.partner_id.id or None args['ref'] = order.contract_number or None - statement_obj= self.pool.get('account.bank.statement') statement_id = statement_obj.search(cr,uid, [ ('journal_id', '=', data['journal']), ('company_id', '=', curr_company), @@ -664,7 +667,7 @@ class pos_order(osv.osv): return order_line_id - def refund(self, cr, uid, ids, context={}): + def refund(self, cr, uid, ids, context=None): """Create a copy of order for refund order""" @@ -691,7 +694,7 @@ class pos_order(osv.osv): }) return clone_list - def action_invoice(self, cr, uid, ids, context={}): + def action_invoice(self, cr, uid, ids, context=None): """Create a invoice of order """ @@ -988,7 +991,7 @@ class pos_order(osv.osv): if not context: context = {} if context.get('flag',False): - self.create_picking(cr, uid, ids, context={}) + self.create_picking(cr, uid, ids, context=None) self.write(cr, uid, ids, {'state': 'paid'}) else: context['flag']=True @@ -1001,7 +1004,7 @@ class pos_order(osv.osv): def action_done(self, cr, uid, ids, context=None): for order in self.browse(cr, uid, ids, context=context): if not order.journal_entry: - self.create_account_move(cr, uid, ids, context={}) + self.create_account_move(cr, uid, ids, context=None) return True def compute_state(self, cr, uid, id): @@ -1168,30 +1171,31 @@ class pos_order_line(osv.osv): 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } - def create(self, cr, user, vals, context={}): + def create(self, cr, user, vals, context=None): if vals.get('product_id'): return super(pos_order_line, self).create(cr, user, vals, context) return False - def write(self, cr, user, ids, values, context={}): + def write(self, cr, user, ids, values, context=None): if 'product_id' in values and not values['product_id']: return False return super(pos_order_line, self).write(cr, user, ids, values, context) def _scan_product(self, cr, uid, ean, qty, order): # search pricelist_id + product_obj=self.pool.get('product.product') pricelist_id = self.pool.get('pos.order').read(cr, uid, [order], ['pricelist_id'] ) if not pricelist_id: return False new_line = True - product_id = self.pool.get('product.product').search(cr, uid, [('ean13','=', ean)]) + product_id = product_obj.search(cr, uid, [('ean13','=', ean)]) if not product_id: return False # search price product - product = self.pool.get('product.product').read(cr, uid, product_id) + product =product_obj.read(cr, uid, product_id) product_name = product[0]['name'] price = self.price_by_product(cr, uid, 0, pricelist_id[0]['pricelist_id'][0], product_id[0], 1) @@ -1231,14 +1235,14 @@ class pos_payment(osv.osv): _name = 'pos.payment' _description = 'Pos Payment' - def _journal_get(self, cr, uid, context={}): + def _journal_get(self, cr, uid, context=None): obj = self.pool.get('account.journal') ids = obj.search(cr, uid, [('type', '=', 'cash')]) res = obj.read(cr, uid, ids, ['id', 'name'], context) res = [(r['id'], r['name']) for r in res] return res - def _journal_default(self, cr, uid, context={}): + def _journal_default(self, cr, uid, context=None): journal_list = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash')]) if journal_list: return journal_list[0] @@ -1261,12 +1265,12 @@ class pos_payment(osv.osv): 'payment_date': lambda *a: time.strftime('%Y-%m-%d'), } - def create(self, cr, user, vals, context={}): + def create(self, cr, user, vals, context=None): if vals.get('journal_id') and vals.get('amount'): return super(pos_payment, self).create(cr, user, vals, context) return False - def write(self, cr, user, ids, values, context={}): + def write(self, cr, user, ids, values, context=None): if 'amount' in values and not values['amount']: return False if 'journal_id' in values and not values['journal_id']: @@ -1278,7 +1282,7 @@ pos_payment() class account_move_line(osv.osv): _inherit = 'account.move.line' - def create(self, cr, user, vals, context={}): + def create(self, cr, user, vals, context=None): pos_obj = self.pool.get('pos.order') val_name = vals.get('name', '') val_ref = vals.get('ref', '') @@ -1299,7 +1303,7 @@ class account_move(osv.osv): _inherit = 'account.move' - def create(self, cr, user, vals, context={}): + def create(self, cr, user, vals, context=None): pos_obj = self.pool.get('pos.order') val_name = vals.get('name', '') val_ref = vals.get('ref', '')