From f2836bbb5f0a3050e7fd7f29935ff00fa2a46563 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Thu, 22 Dec 2011 12:35:17 +0530 Subject: [PATCH 01/36] [ADD] added carrier_cost_delivery.yml in delivery module bzr revid: tpa@tinyerp.com-20111222070517-tzkg4mvdtt93t6re --- addons/delivery/__openerp__.py | 5 ++++- addons/delivery/test/carrier_cost_delivery.yml | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 addons/delivery/test/carrier_cost_delivery.yml diff --git a/addons/delivery/__openerp__.py b/addons/delivery/__openerp__.py index 40dab751f79..301f98cc5b9 100644 --- a/addons/delivery/__openerp__.py +++ b/addons/delivery/__openerp__.py @@ -44,7 +44,10 @@ When creating invoices from picking, OpenERP is able to add and compute the ship 'partner_view.xml' ], 'demo_xml': ['delivery_demo.xml'], - 'test':['test/delivery_report.yml'], + 'test':[ + 'test/delivery_report.yml', + 'test/carrier_cost_delivery.yml', + ], 'installable': True, 'active': False, 'certificate': '0033981912253', diff --git a/addons/delivery/test/carrier_cost_delivery.yml b/addons/delivery/test/carrier_cost_delivery.yml new file mode 100644 index 00000000000..f6ed9c2395b --- /dev/null +++ b/addons/delivery/test/carrier_cost_delivery.yml @@ -0,0 +1,14 @@ +- + IN order to test carrier cost on delivery, +- + I add delivery cost in sale order. +- + !python {model: delivery.sale.order}: | + new_id = self.create(cr ,uid ,{"carrier_id": ref("delivery_carrier")}) + self.delivery_set(cr, uid, [new_id], {'active_id': ref("sale.order")}) +- + I check Delivery cost is added properly or not. +- + !python {model: sale.order.line}: | + line_ids = self.search(cr, uid, [('order_id','=', ref('sale.order')), ('name','=','The Poste')]) + assert len(line_ids), "Delivery cost is not Added" \ No newline at end of file From 27714f2fd27485600803a167a9a58eb0cfa628f4 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 23 Dec 2011 12:23:54 +0530 Subject: [PATCH 02/36] [IMP]Improved YML test cases of delivery module bzr revid: tpa@tinyerp.com-20111223065354-avs0gandnbflwd13 --- addons/delivery/delivery_demo.xml | 2 +- .../delivery/test/carrier_cost_delivery.yml | 49 +++++++++++++++++-- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/addons/delivery/delivery_demo.xml b/addons/delivery/delivery_demo.xml index 94666efb26c..8ec95f14e40 100644 --- a/addons/delivery/delivery_demo.xml +++ b/addons/delivery/delivery_demo.xml @@ -58,7 +58,7 @@ >= price - + diff --git a/addons/delivery/test/carrier_cost_delivery.yml b/addons/delivery/test/carrier_cost_delivery.yml index f6ed9c2395b..e1e4c3e662c 100644 --- a/addons/delivery/test/carrier_cost_delivery.yml +++ b/addons/delivery/test/carrier_cost_delivery.yml @@ -1,14 +1,55 @@ - - IN order to test carrier cost on delivery, + In order to test Carrier Cost on Delivery, - - I add delivery cost in sale order. + I Create Delivery Method. +- + !record {model: delivery.carrier, id: delivery_carrier}: + use_detailed_pricelist: True +- + I Set Delivery Method in Sale order. +- + !record {model: sale.order, id: sale.order}: + carrier_id: delivery_carrier + partner_order_id: base.res_partner_address_8 +- + I add Delivery Cost in Sale order. - !python {model: delivery.sale.order}: | new_id = self.create(cr ,uid ,{"carrier_id": ref("delivery_carrier")}) - self.delivery_set(cr, uid, [new_id], {'active_id': ref("sale.order")}) + id = self.delivery_set(cr, uid, [new_id], {'active_ids': [ref("sale.order")]}) - I check Delivery cost is added properly or not. - !python {model: sale.order.line}: | line_ids = self.search(cr, uid, [('order_id','=', ref('sale.order')), ('name','=','The Poste')]) - assert len(line_ids), "Delivery cost is not Added" \ No newline at end of file + assert len(line_ids), "Delivery cost is not Added" + + line_data = self.browse(cr ,uid ,line_ids[0] ,context) + assert line_data.price_subtotal == 10, "Added Delivey cost is wrong." +- + I set max limit for Delivery cost of Sale order cost will more than max limet then Delivery cost will 0.0. +- + !record {model: delivery.carrier, id: delivery_carrier}: + free_if_more_than: True + amount: 1000 +- + I Set Delivery Method in Sale order of cost of more than max limit. +- + !record {model: sale.order, id: sale.order2}: + carrier_id: delivery_carrier + partner_order_id: base.res_partner_address_8 +- + I add Delivery Cost in Sale order. +- + !python {model: delivery.sale.order}: | + new_id = self.create(cr ,uid ,{"carrier_id": ref("delivery_carrier")}) + self.delivery_set(cr, uid, [new_id], {'active_ids': [ref("sale.order2")]}) +- + I check Delivery cost is added properly or not. +- + !python {model: sale.order.line}: | + line_ids = self.search(cr, uid, [('order_id','=', ref('sale.order2')), ('name','=','The Poste')]) + assert len(line_ids), "Delivery cost is not Added" + + line_data = self.browse(cr ,uid ,line_ids[0] ,context) + #assert line_data.price_subtotal == 0, "Added Delivey cost is wrong." \ No newline at end of file From 57488fe4cdd1c05add58165991822f82b7deb959 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Tue, 27 Dec 2011 18:37:10 +0530 Subject: [PATCH 03/36] [ADD] aded test_bug907211.yml in sale module bzr revid: tpa@tinyerp.com-20111227130710-68c4b3egf60u6dxq --- addons/sale/__openerp__.py | 1 + addons/sale/test/test_bug907211.yml | 68 +++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 addons/sale/test/test_bug907211.yml diff --git a/addons/sale/__openerp__.py b/addons/sale/__openerp__.py index 948352940a0..f455b670c2f 100644 --- a/addons/sale/__openerp__.py +++ b/addons/sale/__openerp__.py @@ -95,6 +95,7 @@ Dashboard for Sales Manager that includes: 'test/cancel_order.yml', 'test/delete_order.yml', 'test/edi_sale_order.yml', + 'test/test_bug907211.yml', ], 'installable': True, 'active': False, diff --git a/addons/sale/test/test_bug907211.yml b/addons/sale/test/test_bug907211.yml new file mode 100644 index 00000000000..dd0678b7aa8 --- /dev/null +++ b/addons/sale/test/test_bug907211.yml @@ -0,0 +1,68 @@ +- + I Create sale order. +- + !record {model: sale.order, id: order_01}: + shop_id: shop + user_id: base.user_root + partner_invoice_id: base.res_partner_address_8 + partner_shipping_id: base.res_partner_address_8 + partner_order_id: base.res_partner_address_8 + order_policy: picking + invoice_quantity: procurement + partner_id: base.res_partner_agrolait + note: 'Invoice after delivery' + payment_term: account.account_payment_term + order_line: + - name: '[PC1] Basic PC' + product_id: product.product_product_pc1 + product_uom: product.product_uom_unit + price_unit: 450.00 + product_uom_qty: 2 + product_uos_qty: 2 + type: make_to_stock + + - name: '[EMPL] Employee' + product_id: product.product_product_employee0 + product_uom: product.uom_hour + price_unit: 200 + product_uom_qty: 3 + product_uos_qty: 3 + type: make_to_stock +- + I confirm the sale order. +- + !workflow {model: sale.order, action: order_confirm, ref: order_01} +- + I send delivery in two shipments, so I am doing a partial delivery order. +- + !python {model: stock.picking}: | + delivery_orders = self.search(cr, uid, [('sale_id','=',ref("order_01"))]) + first_picking = self.browse(cr, uid, delivery_orders[0], context=context) + + if first_picking.force_assign(cr, uid, first_picking): + first_move = first_picking.move_lines[0] + values = {'move%s'%(first_move.id): {'product_qty': 1}} + id = first_picking.do_partial(values, context=context) + + if first_picking.force_assign(cr, uid, first_picking): + first_move = first_picking.move_lines[0] + values = {'move%s'%(first_move.id): {'product_qty': 1}} + id = first_picking.do_partial(values, context=context) +- + I create invoice of both shipment. +- + !python {model: stock.invoice.onshipping}: | + pick_obj = self.pool.get("stock.picking") + + delivery_orders = pick_obj.search(cr, uid, [('sale_id','=',ref("order_01")),('state','=','done'),('invoice_state','=','2binvoiced')]) + new_id = self.create(cr ,uid ,{'group': True,'invoice_date': '2011-12-26','journal_id': '',},{'active_ids': delivery_orders}) + self.open_invoice(cr ,uid ,[new_id],{"active_ids": delivery_orders, "active_id": delivery_orders[0]}) +- + I Check That Invoice is created with proper data or not. +- + !python {model: account.invoice}: | + invoice_ids = self.search(cr ,uid ,[('amount_total','=','2100')] ,context) + invoice = self.browse(cr ,uid ,invoice_ids[0] ,context) + + assert len(invoice.invoice_line) == 4, "Invoice lines are not created properly." + assert invoice.amount_total == 2100, "Invoice total is wrong." \ No newline at end of file From ddc528e7b54df9a33354b1cecd12d0bfbbcb62bc Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Tue, 27 Dec 2011 18:44:33 +0530 Subject: [PATCH 04/36] [IMP] Improved YML string in Delivery module bzr revid: tpa@tinyerp.com-20111227131433-ps9xb2so1apo4jv0 --- addons/delivery/test/carrier_cost_delivery.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/delivery/test/carrier_cost_delivery.yml b/addons/delivery/test/carrier_cost_delivery.yml index e1e4c3e662c..4800d0de011 100644 --- a/addons/delivery/test/carrier_cost_delivery.yml +++ b/addons/delivery/test/carrier_cost_delivery.yml @@ -52,4 +52,4 @@ assert len(line_ids), "Delivery cost is not Added" line_data = self.browse(cr ,uid ,line_ids[0] ,context) - #assert line_data.price_subtotal == 0, "Added Delivey cost is wrong." \ No newline at end of file + #assert line_data.price_subtotal == 0, "Added Delivey cost is wrong." # Due to Bug #908020 \ No newline at end of file From ac5fb95e6de975f6c7c2172cc719e842d2742852 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 28 Dec 2011 15:43:45 +0530 Subject: [PATCH 05/36] [REM]: Removed unnecessary changes. bzr revid: tpa@tinyerp.com-20111228101345-m3t33xtzpusmxy4p --- addons/account_voucher/account_voucher_view.xml | 2 +- addons/point_of_sale/point_of_sale_view.xml | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/addons/account_voucher/account_voucher_view.xml b/addons/account_voucher/account_voucher_view.xml index b791a355a48..cbe35b5fc5f 100644 --- a/addons/account_voucher/account_voucher_view.xml +++ b/addons/account_voucher/account_voucher_view.xml @@ -43,7 +43,7 @@
- + diff --git a/addons/point_of_sale/point_of_sale_view.xml b/addons/point_of_sale/point_of_sale_view.xml index 54ff0f9e131..ba760baeb09 100644 --- a/addons/point_of_sale/point_of_sale_view.xml +++ b/addons/point_of_sale/point_of_sale_view.xml @@ -768,13 +768,7 @@ - - - Launch PoS - - - + web_icon="images/pos.png" web_icon_hover="images/pos-hover.png" groups="point_of_sale.group_pos_manager,point_of_sale.group_pos_user"/> From 49ab30a502bb20e91ff9d6a30e161ba6dc4aabcc Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Thu, 5 Jan 2012 11:10:19 +0100 Subject: [PATCH 06/36] [DUMMY] delivery: style fixes bzr revid: rco@openerp.com-20120105101019-zyzg9exq3kld66ac --- addons/delivery/__openerp__.py | 8 ++++---- addons/delivery/test/carrier_cost_delivery.yml | 2 +- addons/sale/test/test_bug907211.yml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/delivery/__openerp__.py b/addons/delivery/__openerp__.py index 301f98cc5b9..1080face15f 100644 --- a/addons/delivery/__openerp__.py +++ b/addons/delivery/__openerp__.py @@ -44,10 +44,10 @@ When creating invoices from picking, OpenERP is able to add and compute the ship 'partner_view.xml' ], 'demo_xml': ['delivery_demo.xml'], - 'test':[ - 'test/delivery_report.yml', - 'test/carrier_cost_delivery.yml', - ], + 'test': [ + 'test/delivery_report.yml', + 'test/carrier_cost_delivery.yml', + ], 'installable': True, 'active': False, 'certificate': '0033981912253', diff --git a/addons/delivery/test/carrier_cost_delivery.yml b/addons/delivery/test/carrier_cost_delivery.yml index 4800d0de011..75ce503dda2 100644 --- a/addons/delivery/test/carrier_cost_delivery.yml +++ b/addons/delivery/test/carrier_cost_delivery.yml @@ -52,4 +52,4 @@ assert len(line_ids), "Delivery cost is not Added" line_data = self.browse(cr ,uid ,line_ids[0] ,context) - #assert line_data.price_subtotal == 0, "Added Delivey cost is wrong." # Due to Bug #908020 \ No newline at end of file + #assert line_data.price_subtotal == 0, "Added Delivey cost is wrong." # Due to Bug #908020 diff --git a/addons/sale/test/test_bug907211.yml b/addons/sale/test/test_bug907211.yml index dd0678b7aa8..37349d7211c 100644 --- a/addons/sale/test/test_bug907211.yml +++ b/addons/sale/test/test_bug907211.yml @@ -65,4 +65,4 @@ invoice = self.browse(cr ,uid ,invoice_ids[0] ,context) assert len(invoice.invoice_line) == 4, "Invoice lines are not created properly." - assert invoice.amount_total == 2100, "Invoice total is wrong." \ No newline at end of file + assert invoice.amount_total == 2100, "Invoice total is wrong." From b1b2401034f5066a5d3069a027a98ae5b646c40b Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 5 Jan 2012 14:06:24 +0100 Subject: [PATCH 07/36] [imp] improved design of order saving functions bzr revid: nicolas.vanhoren@openerp.com-20120105130624-28ry8w1eo6qnvn5u --- addons/point_of_sale/static/src/js/pos.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/point_of_sale/static/src/js/pos.js b/addons/point_of_sale/static/src/js/pos.js index 371c2c28ca9..b6e842c6bed 100644 --- a/addons/point_of_sale/static/src/js/pos.js +++ b/addons/point_of_sale/static/src/js/pos.js @@ -119,9 +119,9 @@ openerp.point_of_sale = function(db) { self.set({'user': result}); })); }, - push: function(osvModel, record) { + pushOrder: function(record) { var ops = _.clone(this.get('pending_operations')); - ops.push({model: osvModel, record: record}); + ops.push(record); this.set({pending_operations: ops}); return this.flush(); }, @@ -135,11 +135,11 @@ openerp.point_of_sale = function(db) { if (ops.length === 0) return $.when(); var op = ops[0]; - var dataSet = new db.web.DataSet(this, op.model, null); + var dataSet = new db.web.DataSet(this, 'pos.order', null); /* we prevent the default error handler and assume errors * are a normal use case, except we stop the current iteration */ - return dataSet.create(op.record).fail(function(unused, event) { + return dataSet.create(op).fail(function(unused, event) { event.preventDefault(); }).pipe(_.bind(function() { console.debug('saved 1 record'); @@ -937,7 +937,7 @@ openerp.point_of_sale = function(db) { var callback, currentOrder; currentOrder = this.shop.get('selectedOrder'); $('button#validate-order', this.$element).attr('disabled', 'disabled'); - pos.push('pos.order', currentOrder.exportAsJSON()).then(_.bind(function() { + pos.pushOrder(currentOrder.exportAsJSON()).then(_.bind(function() { $('button#validate-order', this.$element).removeAttr('disabled'); return currentOrder.set({ validated: true From 3598bddb7c87fc91d171ffa894a119d33c981d6a Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 5 Jan 2012 14:13:19 +0100 Subject: [PATCH 08/36] [imp] copied order creation login to the server bzr revid: nicolas.vanhoren@openerp.com-20120105131319-9pnr25ms12szttx7 --- addons/point_of_sale/point_of_sale.py | 10 ++++++++++ addons/point_of_sale/static/src/js/pos.js | 3 +-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 60ce7b7bc0c..0810bf459cf 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -22,6 +22,7 @@ import time from datetime import datetime from dateutil.relativedelta import relativedelta +import logging import netsvc from osv import fields, osv @@ -29,6 +30,8 @@ from tools.translate import _ from decimal import Decimal import decimal_precision as dp +_logger = logging.getLogger(__name__) + class pos_config_journal(osv.osv): """ Point of Sale journal configuration""" _name = 'pos.config.journal' @@ -46,6 +49,13 @@ class pos_order(osv.osv): _name = "pos.order" _description = "Point of Sale" _order = "id desc" + + def create_from_ui(self, cr, uid, orders, context=None): + #_logger.info("orders: %r", orders) + list = [] + for order in orders: + list.append(self.create(cr, uid, order, context)) + return list def unlink(self, cr, uid, ids, context=None): for rec in self.browse(cr, uid, ids, context=context): diff --git a/addons/point_of_sale/static/src/js/pos.js b/addons/point_of_sale/static/src/js/pos.js index 3a4f7299713..9b46788a02d 100644 --- a/addons/point_of_sale/static/src/js/pos.js +++ b/addons/point_of_sale/static/src/js/pos.js @@ -135,11 +135,10 @@ openerp.point_of_sale = function(db) { if (ops.length === 0) return $.when(); var op = ops[0]; - var dataSet = new db.web.DataSet(this, 'pos.order', null); /* we prevent the default error handler and assume errors * are a normal use case, except we stop the current iteration */ - return dataSet.create(op).fail(function(unused, event) { + return new db.web.Model("pos.order").get_func("create_from_ui")([op]).fail(function(unused, event) { event.preventDefault(); }).pipe(_.bind(function() { console.debug('saved 1 record'); From 7791dc8ea8f7841110e6246ddbc154f9381bea82 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 5 Jan 2012 14:33:37 +0100 Subject: [PATCH 09/36] [fix] make the workflow progress in pos orders bzr revid: nicolas.vanhoren@openerp.com-20120105133337-1atnng0bh5pqzsfd --- addons/point_of_sale/point_of_sale.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 0810bf459cf..c91b6213230 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -55,6 +55,8 @@ class pos_order(osv.osv): list = [] for order in orders: list.append(self.create(cr, uid, order, context)) + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'pos.order', list[-1], 'paid', cr) return list def unlink(self, cr, uid, ids, context=None): From 5a3f9d7ae09a4f8d4e327db635d8d6cda0ee8b39 Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Thu, 5 Jan 2012 19:20:32 +0530 Subject: [PATCH 10/36] [FIX] set the domain for project time unit bzr revid: nco@tinyerp.com-20120105135032-snh7ue2hm6qxz21r --- addons/project/project_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 8f666067d50..c1b8fedbfb4 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -651,7 +651,7 @@ - + From afba9ceb715944bdc9ff41f41104583aace80596 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 5 Jan 2012 15:18:17 +0100 Subject: [PATCH 11/36] [imp] added algorithm from fp to calculate taxes bzr revid: nicolas.vanhoren@openerp.com-20120105141817-whw7hhlb5ggdeas4 --- addons/point_of_sale/static/src/js/pos.js | 52 +++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/addons/point_of_sale/static/src/js/pos.js b/addons/point_of_sale/static/src/js/pos.js index 9b46788a02d..76c662348f2 100644 --- a/addons/point_of_sale/static/src/js/pos.js +++ b/addons/point_of_sale/static/src/js/pos.js @@ -90,6 +90,7 @@ openerp.point_of_sale = function(db) { this.fetch('account.bank.statement', ['account_id', 'currency', 'journal_id', 'state', 'name'], [['state', '=', 'open'], ['user_id', '=', this.session.uid]]), this.fetch('account.journal', ['auto_cash', 'check_dtls', 'currency', 'name', 'type']), + this.fetch('account.tax', ['amount', 'price_include', 'type']), this.get_app_data()) .pipe(_.bind(this.build_tree, this)); }, @@ -301,6 +302,57 @@ openerp.point_of_sale = function(db) { getTotal: function() { return (this.get('quantity')) * (this.get('list_price')) * (1 - (this.get('discount')) / 100); }, + getPriceWithoutTax: function() { + return getAllPrices().priceWithoutTax; + }, + getPriceWithTax: function() { + return getAllPrices().priceWithTax; + }, + getTax: function() { + return getAllPrices().tax; + }, + getAllPrices: function() { + var self = this; + var totalTax = (this.get('quantity')) * (this.get('list_price')) * (1 - (this.get('discount')) / 100); + var totalNoTax = totalTax; + + var products = pos.store.get('product.product'); + var product = _.detect(products, function(el) {return el.id === self.get('id');}); + var taxes_ids = product.taxes_id; + var taxes = pos.store.get('account.tax'); + var taxtotal = 0; + _.each(taxes_ids, function(el) { + var tax = _.detect(taxes, function(t) {return t.id === el;}); + if (tax.price_include) { + var tmp; + if (tax.type === "percent") { + tmp = tax.amount / (1 + self.getTotalWithoutTax()); + } else if (tax.type === "fixed") { + tmp = tax.amount * self.get('quantity'); + } else { + throw "This type of tax is not supported by the point of sale: " + tax.type; + } + taxtotal += tmp; + totalNoTax -= tmp; + } else { + var tmp; + if (tax.type === "percent") { + tmp = tax.amount * self.getTotalWithoutTax(); + } else if (tax.type === "fixed") { + tmp = tax.amount * self.get('quantity'); + } else { + throw "This type of tax is not supported by the point of sale: " + tax.type; + } + taxtotal += tmp; + totalTax += tmp; + } + }); + return { + "priceWithTax": totalTax, + "priceWithoutTax": totalNoTax, + "tax": taxtotal, + }; + }, exportAsJSON: function() { var result; result = { From 8d598e49e32799cf9e260c0eadd41fcbdb8b1c56 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 5 Jan 2012 15:35:30 +0100 Subject: [PATCH 12/36] [imp] switched to correct tax calculation bzr revid: nicolas.vanhoren@openerp.com-20120105143530-8rhlec72g9gt0q80 --- addons/point_of_sale/static/src/js/pos.js | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/addons/point_of_sale/static/src/js/pos.js b/addons/point_of_sale/static/src/js/pos.js index 76c662348f2..133c646503a 100644 --- a/addons/point_of_sale/static/src/js/pos.js +++ b/addons/point_of_sale/static/src/js/pos.js @@ -299,22 +299,20 @@ openerp.point_of_sale = function(db) { quantity: (this.get('quantity')) + 1 }); }, - getTotal: function() { - return (this.get('quantity')) * (this.get('list_price')) * (1 - (this.get('discount')) / 100); - }, getPriceWithoutTax: function() { - return getAllPrices().priceWithoutTax; + return this.getAllPrices().priceWithoutTax; }, getPriceWithTax: function() { - return getAllPrices().priceWithTax; + return this.getAllPrices().priceWithTax; }, getTax: function() { - return getAllPrices().tax; + return this.getAllPrices().tax; }, getAllPrices: function() { var self = this; - var totalTax = (this.get('quantity')) * (this.get('list_price')) * (1 - (this.get('discount')) / 100); - var totalNoTax = totalTax; + var base = (this.get('quantity')) * (this.get('list_price')) * (1 - (this.get('discount')) / 100); + var totalTax = base; + var totalNoTax = base; var products = pos.store.get('product.product'); var product = _.detect(products, function(el) {return el.id === self.get('id');}); @@ -326,7 +324,7 @@ openerp.point_of_sale = function(db) { if (tax.price_include) { var tmp; if (tax.type === "percent") { - tmp = tax.amount / (1 + self.getTotalWithoutTax()); + tmp = base - (base / (1 + tax.amount)); } else if (tax.type === "fixed") { tmp = tax.amount * self.get('quantity'); } else { @@ -337,7 +335,7 @@ openerp.point_of_sale = function(db) { } else { var tmp; if (tax.type === "percent") { - tmp = tax.amount * self.getTotalWithoutTax(); + tmp = tax.amount * base; } else if (tax.type === "fixed") { tmp = tax.amount * self.get('quantity'); } else { @@ -465,14 +463,18 @@ openerp.point_of_sale = function(db) { }; Order.prototype.getTotal = function() { return (this.get('orderLines')).reduce((function(sum, orderLine) { - return sum + orderLine.getTotal(); + return sum + orderLine.getPriceWithTax(); }), 0); }; Order.prototype.getTotalTaxExcluded = function() { - return this.getTotal() / 1.21; + return (this.get('orderLines')).reduce((function(sum, orderLine) { + return sum + orderLine.getPriceWithoutTax(); + }), 0); }; Order.prototype.getTax = function() { - return this.getTotal() / 1.21 * 0.21; + return (this.get('orderLines')).reduce((function(sum, orderLine) { + return sum + orderLine.getTax(); + }), 0); }; Order.prototype.getPaidTotal = function() { return (this.get('paymentLines')).reduce((function(sum, paymentLine) { From a84956a5cc451f00abaa4f1686b317fa4f62e793 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 6 Jan 2012 10:29:30 +0100 Subject: [PATCH 13/36] [FIX] product: field parent_id of product.category should be set as ondelete='cascade' bzr revid: rco@openerp.com-20120106092930-0r3eaa1hvcc0h4ce --- addons/product/product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/product/product.py b/addons/product/product.py index a443ebe6033..e6b4b4c6348 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -214,7 +214,7 @@ class product_category(osv.osv): _columns = { 'name': fields.char('Name', size=64, required=True, translate=True, select=True), 'complete_name': fields.function(_name_get_fnc, type="char", string='Name'), - 'parent_id': fields.many2one('product.category','Parent Category', select=True), + 'parent_id': fields.many2one('product.category','Parent Category', select=True, ondelete='cascade'), 'child_id': fields.one2many('product.category', 'parent_id', string='Child Categories'), 'sequence': fields.integer('Sequence', select=True, help="Gives the sequence order when displaying a list of product categories."), 'type': fields.selection([('view','View'), ('normal','Normal')], 'Category Type'), From 2439ec675b51dda3793579902102f932da980d95 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 6 Jan 2012 11:02:51 +0100 Subject: [PATCH 14/36] [imp] improved to newer version of lib client bzr revid: nicolas.vanhoren@openerp.com-20120106100251-1dzh2j4zaxax9px2 --- addons/web/common/openerplib/main.py | 16 ++-------------- addons/web/common/session.py | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/addons/web/common/openerplib/main.py b/addons/web/common/openerplib/main.py index 84484e49ae6..2cbf9692063 100644 --- a/addons/web/common/openerplib/main.py +++ b/addons/web/common/openerplib/main.py @@ -140,8 +140,7 @@ class Connection(object): database=None, login=None, password=None, - user_id=None, - auto_context=True): + user_id=None): """ Initialize with login information. The login information is facultative to allow specifying it after the initialization of this object. @@ -152,15 +151,11 @@ class Connection(object): :param password: The password of the user. :param user_id: The user id is a number identifying the user. This is only useful if you already know it, in most cases you don't need to specify it. - :param auto_context: If true, automatically queries the context of the user and adds it to all - method calls on models. If a context is already specified, the contexts are merged with it (the - user context has the lowest priority). Default to True. """ self.connector = connector self.set_login_info(database, login, password, user_id) self.user_context = None - self.auto_context = auto_context def set_login_info(self, database, login, password, user_id=None): """ @@ -202,9 +197,7 @@ class Connection(object): Query the default context of the user. """ if not self.user_context: - mod = self.get_model('res.users') - mod.override_auto_context = False - self.user_context = mod.context_get() + self.user_context = self.get_model('res.users').context_get() return self.user_context def get_model(self, model_name): @@ -244,7 +237,6 @@ class Model(object): """ self.connection = connection self.model_name = model_name - self.override_auto_context = None self.__logger = _getChildLogger(_getChildLogger(_logger, 'object'), model_name or "") def __getattr__(self, method): @@ -259,10 +251,6 @@ class Model(object): """ self.connection.check_login(False) self.__logger.debug(args) - if (self.override_auto_context is not None and self.override_auto_context) or \ - (self.override_auto_context is None and self.connection.auto_context): - kw = dict(kw) - kw['context'] = dict(self.connection.get_user_context(), **kw.get('context', {})) result = self.connection.get_service('object').execute_kw( self.connection.database, self.connection.user_id, diff --git a/addons/web/common/session.py b/addons/web/common/session.py index 4202ce45507..905670404a9 100644 --- a/addons/web/common/session.py +++ b/addons/web/common/session.py @@ -53,7 +53,7 @@ class OpenERPSession(object): def build_connection(self): conn = openerplib.Connection(self.config.connector, database=self._db, login=self._login, - user_id=self._uid, password=self._password, auto_context=False) + user_id=self._uid, password=self._password) return conn def proxy(self, service): From 666ed25b4d120079a8e52424af9d01047c7a60dd Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 6 Jan 2012 11:03:31 +0100 Subject: [PATCH 15/36] [imp] simplified buffered dataset bzr revid: nicolas.vanhoren@openerp.com-20120106100331-ouggh486o1zab1vz --- addons/web/static/src/js/data.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index a87b6deebda..35cffe251cb 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -688,9 +688,7 @@ openerp.web.BufferedDataSet = openerp.web.DataSetStatic.extend({ this.cache = _.reject(this.cache, function(x) { return _.include(ids, x.id);}); this.set_ids(_.without.apply(_, [this.ids].concat(ids))); this.on_change(); - var to_return = $.Deferred().then(callback); - $.async_when().then(function () {to_return.resolve({result: true});}); - return to_return.promise(); + return $.async_when({result: true}).then(callback); }, reset_ids: function(ids) { this.set_ids(ids); @@ -787,9 +785,7 @@ openerp.web.ProxyDataSet = openerp.web.DataSetSearch.extend({ return this.create_function(data, callback, error_callback); } else { console.warn("trying to create a record using default proxy dataset behavior"); - var to_return = $.Deferred().then(callback); - $.async_when().then(function () {to_return.resolve({"result": undefined});}); - return to_return.promise(); + return $.async_when({"result": undefined}).then(callback); } }, on_create: function(data) {}, @@ -799,18 +795,14 @@ openerp.web.ProxyDataSet = openerp.web.DataSetSearch.extend({ return this.write_function(id, data, options, callback); } else { console.warn("trying to write a record using default proxy dataset behavior"); - var to_return = $.Deferred().then(callback); - $.async_when().then(function () {to_return.resolve({"result": true});}); - return to_return.promise(); + return $.async_when({"result": true}).then(callback); } }, on_write: function(id, data) {}, unlink: function(ids, callback, error_callback) { this.on_unlink(ids); console.warn("trying to unlink a record using default proxy dataset behavior"); - var to_return = $.Deferred().then(callback); - $.async_when().then(function () {to_return.resolve({"result": true});}); - return to_return.promise(); + return $.async_when({"result": true}).then(callback); }, on_unlink: function(ids) {} }); From 7fb8b668a5c96e20bb8008d25ff62797e2b737da Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 6 Jan 2012 11:16:19 +0100 Subject: [PATCH 16/36] [imp] re used context retreival bzr revid: nicolas.vanhoren@openerp.com-20120106101619-d0po1e513o2gti2b --- addons/web/common/session.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/web/common/session.py b/addons/web/common/session.py index 905670404a9..ac0489b2ff3 100644 --- a/addons/web/common/session.py +++ b/addons/web/common/session.py @@ -107,8 +107,7 @@ class OpenERPSession(object): :returns: the new context """ assert self._uid, "The user needs to be logged-in to initialize his context" - self.context = self.model('res.users').context_get(self.context) - self.context = self.context or {} + self.context = self.build_connection().get_user_context() or {} return self.context From 3030b86ba6bb3a7a456c16e1d6b5170cc4796896 Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Fri, 6 Jan 2012 15:56:38 +0530 Subject: [PATCH 17/36] [ADD]: ADD mail module in import_base dependency. bzr revid: atp@tinyerp.com-20120106102638-ynkw8h3r5dj02ldf --- addons/import_base/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/import_base/__openerp__.py b/addons/import_base/__openerp__.py index 742e16dfe80..affb06aa11c 100644 --- a/addons/import_base/__openerp__.py +++ b/addons/import_base/__openerp__.py @@ -29,7 +29,7 @@ """, 'author': 'OpenERP SA', 'website': 'http://www.openerp.com', - 'depends': ['base'], + 'depends': ['base','mail'], 'init_xml': [], 'update_xml': ["import_base_view.xml"], 'demo_xml': [], From 0f724c68f8b7585d522d172cd58c96338e0b3ec2 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 6 Jan 2012 11:32:19 +0100 Subject: [PATCH 18/36] [imp] added method to call a model method with kwargs bzr revid: nicolas.vanhoren@openerp.com-20120106103219-4t633kov3hsz50tj --- addons/web/controllers/main.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 65002d52d7a..852d5138177 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -833,17 +833,29 @@ class DataSet(openerpweb.Controller): if has_context: args[context_id] = c + return self._call_kw(req, model, method, args, {}) + + def _call_kw(self, req, model, method, args, kwargs): for i in xrange(len(args)): if isinstance(args[i], web.common.nonliterals.BaseContext): args[i] = req.session.eval_context(args[i]) - if isinstance(args[i], web.common.nonliterals.BaseDomain): + elif isinstance(args[i], web.common.nonliterals.BaseDomain): args[i] = req.session.eval_domain(args[i]) + for k in kwargs.keys(): + if isinstance(kwargs[k], web.common.nonliterals.BaseContext): + kwargs[k] = req.session.eval_context(kwargs[k]) + elif isinstance(kwargs[k], web.common.nonliterals.BaseDomain): + kwargs[k] = req.session.eval_domain(kwargs[k]) - return getattr(req.session.model(model), method)(*args) + return getattr(req.session.model(model), method)(*args, **kwargs) @openerpweb.jsonrequest def call(self, req, model, method, args, domain_id=None, context_id=None): return self.call_common(req, model, method, args, domain_id, context_id) + + @openerpweb.jsonrequest + def call_kw(self, req, model, method, args, kwargs): + return self._call_kw(req, model, method, args, kwargs) @openerpweb.jsonrequest def call_button(self, req, model, method, args, domain_id=None, context_id=None): From b2bb12cb35d99d303bb4111ef13bf9a93b4740e7 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 6 Jan 2012 16:04:12 +0530 Subject: [PATCH 19/36] [FIX]create attachment for applicant has done any survey answer bzr revid: sgo@tinyerp.com-20120106103412-2ob2zza4d4bptes5 --- addons/survey/wizard/survey_answer.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index a4b67896e89..d83166b8609 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -22,7 +22,7 @@ import os import datetime from lxml import etree from time import strftime - +import base64 import tools import netsvc from osv import osv @@ -425,6 +425,7 @@ class survey_question_wiz(osv.osv_memory): result['arch'] = etree.tostring(root) result['fields'] = {} result['context'] = context + return result def create_report(self, cr, uid, res_ids, report_name=False, file_name=False, context=None): @@ -441,6 +442,16 @@ class survey_question_wiz(osv.osv_memory): fp = open(ret_file_name, 'wb+'); fp.write(result); fp.close(); + if context.get('active_model') == 'hr.applicant': + result = base64.b64encode(result) + file_name = file_name + '.pdf' + ir_attachment = self.pool.get('ir.attachment').create(cr, uid, + {'name': file_name, + 'datas': result, + 'datas_fname': file_name, + 'res_model': context.get('active_model'), + 'res_id': context.get('active_ids')[0]}, + context=context) except Exception,e: return (False, str(e)) From 53144e6ed81541696ea41fedf5dfea7fea228277 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 6 Jan 2012 11:40:09 +0100 Subject: [PATCH 20/36] [imp] improved js-side Model class bzr revid: nicolas.vanhoren@openerp.com-20120106104009-67z8ofmo4ndl4651 --- addons/web/static/src/js/data.js | 36 +++++++------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 35cffe251cb..c24325a9327 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -816,43 +816,23 @@ openerp.web.Model = openerp.web.CallbackEnabled.extend({ var c = openerp.connection; return c.rpc.apply(c, arguments); }, + /* + * deprecated because it does not allow to specify kwargs, directly use call() instead + */ get_func: function(method_name) { var self = this; return function() { - if (method_name == "search_read") - return self._search_read.apply(self, arguments); - return self._call(method_name, _.toArray(arguments)); + return self.call(method_name, _.toArray(arguments), {}); }; }, - _call: function (method, args) { - return this.rpc('/web/dataset/call', { + call: function (method, args, kwargs) { + return this.rpc('/web/dataset/call_kw', { model: this.model_name, method: method, - args: args - }).pipe(function(result) { - if (method == "read" && result instanceof Array && result.length > 0 && result[0]["id"]) { - var index = {}; - _.each(_.range(result.length), function(i) { - index[result[i]["id"]] = result[i]; - }); - result = _.map(args[0], function(x) {return index[x];}); - } - return result; + args: args, + kwargs: kwargs, }); }, - _search_read: function(domain, fields, offset, limit, order, context) { - return this.rpc('/web/dataset/search_read', { - model: this.model_name, - fields: fields, - offset: offset, - limit: limit, - domain: domain, - sort: order, - context: context - }).pipe(function(result) { - return result.records; - }); - } }); openerp.web.CompoundContext = openerp.web.Class.extend({ From 45b6a10934993a7dc9c5cf96214898990df7bbc2 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 6 Jan 2012 12:09:14 +0100 Subject: [PATCH 21/36] [imp] converted all remaining usage of default_get in xml to context bzr revid: nicolas.vanhoren@openerp.com-20120106110914-qsbvuc34ietfmtg2 --- addons/account/account_invoice_view.xml | 2 +- addons/account/account_view.xml | 2 +- addons/account_payment/account_payment_view.xml | 2 +- addons/account_voucher/account_voucher_view.xml | 2 +- .../voucher_payment_receipt_view.xml | 12 ++++++------ .../voucher_sales_purchase_view.xml | 4 ++-- addons/survey/survey_view.xml | 16 ++++++++-------- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index e198e9e3069..8a3046ca9b6 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -169,7 +169,7 @@ - + diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 9b33c1ed364..3d34396248b 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1363,7 +1363,7 @@ - + diff --git a/addons/account_payment/account_payment_view.xml b/addons/account_payment/account_payment_view.xml index 3fc2d716e66..00c4b15b252 100644 --- a/addons/account_payment/account_payment_view.xml +++ b/addons/account_payment/account_payment_view.xml @@ -110,7 +110,7 @@