From 9b31288c14613f62bd339dd29050e570100c088e Mon Sep 17 00:00:00 2001 From: "Ravish (Open ERP)" Date: Mon, 4 Mar 2013 16:25:32 +0530 Subject: [PATCH 1/7] currecy_so_po bzr revid: rmu@tinyerp.com-20130304105532-hzwakhr1y71q88iz --- addons/product/security/product_security.xml | 2 ++ addons/purchase/purchase.py | 3 ++- addons/purchase/purchase_view.xml | 2 +- addons/sale/sale.py | 5 +++-- addons/sale/sale_view.xml | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/product/security/product_security.xml b/addons/product/security/product_security.xml index 2e6bdac9fca..bf528160464 100644 --- a/addons/product/security/product_security.xml +++ b/addons/product/security/product_security.xml @@ -10,11 +10,13 @@ Sales Pricelists + Purchase Pricelists + diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index e76bf4a0358..4a37e28b96f 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -184,7 +184,7 @@ class purchase_order(osv.osv): 'warehouse_id': fields.many2one('stock.warehouse', 'Destination Warehouse'), 'location_id': fields.many2one('stock.location', 'Destination', required=True, domain=[('usage','<>','view')], states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]} ), 'pricelist_id':fields.many2one('product.pricelist', 'Pricelist', required=True, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]}, help="The pricelist sets the currency used for this purchase order. It also computes the supplier price for the selected products/quantities."), - 'currency_id': fields.related('pricelist_id', 'currency_id', type="many2one", relation="res.currency", string="Currency",readonly=True, required=True), + 'currency_id': fields.many2one('res.currency','Currency', readonly=True, required=True,states={'draft': [('readonly', False)],'sent': [('readonly', False)]}), 'state': fields.selection(STATE_SELECTION, 'Status', readonly=True, help="The status of the purchase order or the quotation request. A quotation is a purchase order in a 'Draft' status. Then the order has to be confirmed by the user, the status switch to 'Confirmed'. Then the supplier must confirm the order to change the status to 'Approved'. When the purchase order is paid and received, the status becomes 'Done'. If a cancel action occurs in the invoice or in the reception of goods, the status becomes in exception.", select=True), 'order_line': fields.one2many('purchase.order.line', 'order_id', 'Order Lines', states={'approved':[('readonly',True)],'done':[('readonly',True)]}), 'validator' : fields.many2one('res.users', 'Validated by', readonly=True), @@ -224,6 +224,7 @@ class purchase_order(osv.osv): 'create_uid': fields.many2one('res.users', 'Responsible'), 'company_id': fields.many2one('res.company','Company',required=True,select=1, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}), 'journal_id': fields.many2one('account.journal', 'Journal'), + 'currency_id': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id } _defaults = { 'date_order': fields.date.context_today, diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 8ba730567e2..a365b719f6a 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -191,7 +191,7 @@ - + diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 8656dccd5db..0e4e1333e53 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -215,7 +215,7 @@ class sale_order(osv.osv): help="""This field controls how invoice and delivery operations are synchronized. - With 'Before Delivery', a draft invoice is created, and it must be paid before delivery."""), 'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="Pricelist for current sales order."), - 'currency_id': fields.related('pricelist_id', 'currency_id', type="many2one", relation="res.currency", string="Currency", readonly=True, required=True), + 'currency_id': fields.many2one('res.currency','Currency', readonly=True, required=True,states={'draft': [('readonly', False)],'sent': [('readonly', False)]}), 'project_id': fields.many2one('account.analytic.account', 'Contract / Analytic', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="The analytic account related to a sales order."), 'order_line': fields.one2many('sale.order.line', 'order_id', 'Order Lines', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}), @@ -261,7 +261,8 @@ class sale_order(osv.osv): 'shop_id': _get_default_shop, 'partner_invoice_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['invoice'])['invoice'], 'partner_shipping_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['delivery'])['delivery'], - 'note': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.sale_note + 'note': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.sale_note, + 'currency_id': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id } _sql_constraints = [ ('name_uniq', 'unique(name, company_id)', 'Order Reference must be unique per Company!'), diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index f4b8283f9b4..115f5dad79c 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -163,7 +163,7 @@ - + From cca957c7169f5a72f25a3e7f0ed9d397091bb5f1 Mon Sep 17 00:00:00 2001 From: "Ravish (Open ERP)" Date: Mon, 4 Mar 2013 16:52:06 +0530 Subject: [PATCH 2/7] currecy_so_po_improve bzr revid: rmu@tinyerp.com-20130304112206-dk1486i17igx33g0 --- addons/purchase/purchase.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 4a37e28b96f..4c534265763 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -224,7 +224,7 @@ class purchase_order(osv.osv): 'create_uid': fields.many2one('res.users', 'Responsible'), 'company_id': fields.many2one('res.company','Company',required=True,select=1, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}), 'journal_id': fields.many2one('account.journal', 'Journal'), - 'currency_id': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id + } _defaults = { 'date_order': fields.date.context_today, @@ -236,6 +236,7 @@ class purchase_order(osv.osv): 'pricelist_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').browse(cr, uid, context['partner_id']).property_product_pricelist_purchase.id, 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'purchase.order', context=c), 'journal_id': _get_journal, + 'currency_id': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id } _sql_constraints = [ ('name_uniq', 'unique(name, company_id)', 'Order Reference must be unique per Company!'), From 1ee33ffb205e7ee2adc42ffa42eac7a50e6f7ad9 Mon Sep 17 00:00:00 2001 From: "Ravish (Open ERP)" Date: Tue, 5 Mar 2013 10:14:47 +0530 Subject: [PATCH 3/7] changes as per suggestion bzr revid: rmu@tinyerp.com-20130305044447-iuyiw2o8epioaajt --- addons/product/security/product_security.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/product/security/product_security.xml b/addons/product/security/product_security.xml index bf528160464..2e6bdac9fca 100644 --- a/addons/product/security/product_security.xml +++ b/addons/product/security/product_security.xml @@ -10,13 +10,11 @@ Sales Pricelists - Purchase Pricelists - From 821e05f4771d8597f79cd7970fa5a573f807ba79 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Thu, 23 May 2013 16:18:20 +0530 Subject: [PATCH 4/7] [IMP] upadte the currency in invoices bzr revid: rma@tinyerp.com-20130523104820-1qp3zcd8oubz2329 --- addons/purchase/purchase.py | 2 +- addons/purchase/wizard/purchase_line_invoice.py | 3 ++- addons/sale/sale.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index ec149cbac15..7fa4ce2fb7f 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -546,7 +546,7 @@ class purchase_order(osv.osv): 'account_id': pay_acc_id, 'type': 'in_invoice', 'partner_id': order.partner_id.id, - 'currency_id': order.pricelist_id.currency_id.id, + 'currency_id': order.currency_id.id, 'journal_id': len(journal_ids) and journal_ids[0] or False, 'invoice_line': [(6, 0, inv_lines)], 'origin': order.name, diff --git a/addons/purchase/wizard/purchase_line_invoice.py b/addons/purchase/wizard/purchase_line_invoice.py index f97d82a8456..a46162edaf1 100644 --- a/addons/purchase/wizard/purchase_line_invoice.py +++ b/addons/purchase/wizard/purchase_line_invoice.py @@ -64,6 +64,7 @@ class purchase_line_invoice(osv.osv_memory): def make_invoice_by_partner(partner, orders, lines_ids): + """ create a new invoice for one supplier @param partner : The object partner @@ -83,7 +84,7 @@ class purchase_line_invoice(osv.osv_memory): 'account_id': a, 'partner_id': partner.id, 'invoice_line': [(6,0,lines_ids)], - 'currency_id' : orders[0].pricelist_id.currency_id.id, + 'currency_id' : orders[0].currency_id.id, 'comment': multiple_order_invoice_notes(orders), 'payment_term': orders[0].payment_term_id.id, 'fiscal_position': partner.property_account_position.id diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 062ca599eb0..d519db7e02a 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -385,7 +385,7 @@ class sale_order(osv.osv): 'partner_id': order.partner_invoice_id.id, 'journal_id': journal_ids[0], 'invoice_line': [(6, 0, lines)], - 'currency_id': order.pricelist_id.currency_id.id, + 'currency_id': order.currency_id.id, 'comment': order.note, 'payment_term': order.payment_term and order.payment_term.id or False, 'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id, From c96dc3303f301ca8291de6b966393917427bc087 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Thu, 23 May 2013 16:33:43 +0530 Subject: [PATCH 5/7] [IMP] code improve bzr revid: rma@tinyerp.com-20130523110343-owr25x1mmr2joheu --- addons/purchase/purchase.py | 2 +- addons/purchase/wizard/purchase_line_invoice.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 7fa4ce2fb7f..54d167d5fa1 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -226,7 +226,7 @@ class purchase_order(osv.osv): 'create_uid': fields.many2one('res.users', 'Responsible'), 'company_id': fields.many2one('res.company','Company',required=True,select=1, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}), 'journal_id': fields.many2one('account.journal', 'Journal'), - + } _defaults = { 'date_order': fields.date.context_today, diff --git a/addons/purchase/wizard/purchase_line_invoice.py b/addons/purchase/wizard/purchase_line_invoice.py index a46162edaf1..051441d1095 100644 --- a/addons/purchase/wizard/purchase_line_invoice.py +++ b/addons/purchase/wizard/purchase_line_invoice.py @@ -64,7 +64,7 @@ class purchase_line_invoice(osv.osv_memory): def make_invoice_by_partner(partner, orders, lines_ids): - + """ create a new invoice for one supplier @param partner : The object partner From dc36531d7c97791a1e2fbf944f928fd01d4557ff Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Thu, 23 May 2013 17:50:45 +0530 Subject: [PATCH 6/7] [IMP] change currency for diffrent invoice methods bzr revid: rma@tinyerp.com-20130523122045-zy0nf24nkbepymd8 --- addons/purchase/stock.py | 4 ++-- addons/sale/wizard/sale_line_invoice.py | 2 +- addons/sale/wizard/sale_make_invoice_advance.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index e64c12a2359..be4169c4624 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -70,7 +70,7 @@ class stock_picking(osv.osv): def get_currency_id(self, cursor, user, picking): if picking.purchase_id: - return picking.purchase_id.pricelist_id.currency_id.id + return picking.purchase_id.currency_id.id else: return super(stock_picking, self).get_currency_id(cursor, user, picking) @@ -129,7 +129,7 @@ class stock_partial_picking(osv.osv_memory): def _product_cost_for_average_update(self, cr, uid, move): if move.picking_id.purchase_id: return {'cost': move.purchase_line_id.price_unit, - 'currency': move.picking_id.purchase_id.pricelist_id.currency_id.id} + 'currency': move.picking_id.purchase_id.currency_id.id} return super(stock_partial_picking, self)._product_cost_for_average_update(cr, uid, move) # Redefinition of the new field in order to update the model stock.picking.in in the orm diff --git a/addons/sale/wizard/sale_line_invoice.py b/addons/sale/wizard/sale_line_invoice.py index 3b04319f5c7..06aae9ea6d5 100644 --- a/addons/sale/wizard/sale_line_invoice.py +++ b/addons/sale/wizard/sale_line_invoice.py @@ -68,7 +68,7 @@ class sale_order_line_make_invoice(osv.osv_memory): 'account_id': a, 'partner_id': order.partner_invoice_id.id, 'invoice_line': [(6, 0, lines)], - 'currency_id' : order.pricelist_id.currency_id.id, + 'currency_id' : order.currency_id.id, 'comment': order.note, 'payment_term': pay_term, 'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id, diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py index 4cb00245ade..68446778323 100644 --- a/addons/sale/wizard/sale_make_invoice_advance.py +++ b/addons/sale/wizard/sale_make_invoice_advance.py @@ -141,7 +141,7 @@ class sale_advance_payment_inv(osv.osv_memory): 'account_id': sale.partner_id.property_account_receivable.id, 'partner_id': sale.partner_invoice_id.id, 'invoice_line': [(0, 0, inv_line_values)], - 'currency_id': sale.pricelist_id.currency_id.id, + 'currency_id': sale.currency_id.id, 'comment': '', 'payment_term': sale.payment_term.id, 'fiscal_position': sale.fiscal_position.id or sale.partner_id.property_account_position.id From c4cbd56be61ee747c4be3be335bed4b140d040fa Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Mon, 27 May 2013 16:42:16 +0530 Subject: [PATCH 7/7] [IMP] remove unnecessary chnages bzr revid: rma@tinyerp.com-20130527111216-dyo8qprm6zh5u3cj --- addons/purchase/purchase.py | 1 - addons/purchase/wizard/purchase_line_invoice.py | 1 - addons/sale/sale.py | 7 +++---- addons/sale/sale_view.xml | 2 +- addons/sale/wizard/sale_line_invoice.py | 2 +- addons/sale/wizard/sale_make_invoice_advance.py | 2 +- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 54d167d5fa1..0ad39fca4f8 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -226,7 +226,6 @@ class purchase_order(osv.osv): 'create_uid': fields.many2one('res.users', 'Responsible'), 'company_id': fields.many2one('res.company','Company',required=True,select=1, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}), 'journal_id': fields.many2one('account.journal', 'Journal'), - } _defaults = { 'date_order': fields.date.context_today, diff --git a/addons/purchase/wizard/purchase_line_invoice.py b/addons/purchase/wizard/purchase_line_invoice.py index 051441d1095..b8ee4b69a32 100644 --- a/addons/purchase/wizard/purchase_line_invoice.py +++ b/addons/purchase/wizard/purchase_line_invoice.py @@ -64,7 +64,6 @@ class purchase_line_invoice(osv.osv_memory): def make_invoice_by_partner(partner, orders, lines_ids): - """ create a new invoice for one supplier @param partner : The object partner diff --git a/addons/sale/sale.py b/addons/sale/sale.py index d519db7e02a..210e4dd3be6 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -212,7 +212,7 @@ class sale_order(osv.osv): ], 'Create Invoice', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="""This field controls how invoice and delivery operations are synchronized."""), 'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="Pricelist for current sales order."), - 'currency_id': fields.many2one('res.currency','Currency', readonly=True, required=True,states={'draft': [('readonly', False)],'sent': [('readonly', False)]}), + 'currency_id': fields.related('pricelist_id', 'currency_id', type="many2one", relation="res.currency", string="Currency", readonly=True, required=True), 'project_id': fields.many2one('account.analytic.account', 'Contract / Analytic', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="The analytic account related to a sales order."), 'order_line': fields.one2many('sale.order.line', 'order_id', 'Order Lines', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}), @@ -258,8 +258,7 @@ class sale_order(osv.osv): 'shop_id': _get_default_shop, 'partner_invoice_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['invoice'])['invoice'], 'partner_shipping_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['delivery'])['delivery'], - 'note': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.sale_note, - 'currency_id': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id + 'note': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.sale_note } _sql_constraints = [ ('name_uniq', 'unique(name, company_id)', 'Order Reference must be unique per Company!'), @@ -385,7 +384,7 @@ class sale_order(osv.osv): 'partner_id': order.partner_invoice_id.id, 'journal_id': journal_ids[0], 'invoice_line': [(6, 0, lines)], - 'currency_id': order.currency_id.id, + 'currency_id': order.pricelist_id.currency_id.id, 'comment': order.note, 'payment_term': order.payment_term and order.payment_term.id or False, 'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id, diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index d1826da02c1..e24a6e45fe0 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -163,7 +163,7 @@ - + diff --git a/addons/sale/wizard/sale_line_invoice.py b/addons/sale/wizard/sale_line_invoice.py index 06aae9ea6d5..3b04319f5c7 100644 --- a/addons/sale/wizard/sale_line_invoice.py +++ b/addons/sale/wizard/sale_line_invoice.py @@ -68,7 +68,7 @@ class sale_order_line_make_invoice(osv.osv_memory): 'account_id': a, 'partner_id': order.partner_invoice_id.id, 'invoice_line': [(6, 0, lines)], - 'currency_id' : order.currency_id.id, + 'currency_id' : order.pricelist_id.currency_id.id, 'comment': order.note, 'payment_term': pay_term, 'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id, diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py index 68446778323..4cb00245ade 100644 --- a/addons/sale/wizard/sale_make_invoice_advance.py +++ b/addons/sale/wizard/sale_make_invoice_advance.py @@ -141,7 +141,7 @@ class sale_advance_payment_inv(osv.osv_memory): 'account_id': sale.partner_id.property_account_receivable.id, 'partner_id': sale.partner_invoice_id.id, 'invoice_line': [(0, 0, inv_line_values)], - 'currency_id': sale.currency_id.id, + 'currency_id': sale.pricelist_id.currency_id.id, 'comment': '', 'payment_term': sale.payment_term.id, 'fiscal_position': sale.fiscal_position.id or sale.partner_id.property_account_position.id