diff --git a/addons/account/partner.py b/addons/account/partner.py index f582da6b765..a7df31b2f32 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -189,44 +189,34 @@ class res_partner(osv.osv): 'debit': fields.function(_credit_debit_get, fnct_search=_debit_search, string='Total Payable', multi='dc', help="Total amount you have to pay to this supplier."), 'debit_limit': fields.float('Payable Limit'), 'property_account_payable': fields.property( - 'account.account', type='many2one', relation='account.account', string="Account Payable", - view_load=True, domain="[('type', '=', 'payable')]", help="This account will be used instead of the default one as the payable account for the current partner", required=True), 'property_account_receivable': fields.property( - 'account.account', type='many2one', relation='account.account', string="Account Receivable", - view_load=True, domain="[('type', '=', 'receivable')]", help="This account will be used instead of the default one as the receivable account for the current partner", required=True), 'property_account_position': fields.property( - 'account.fiscal.position', type='many2one', relation='account.fiscal.position', string="Fiscal Position", - view_load=True, help="The fiscal position will determine taxes and accounts used for the partner.", ), 'property_payment_term': fields.property( - 'account.payment.term', type='many2one', relation='account.payment.term', string ='Customer Payment Term', - view_load=True, help="This payment term will be used instead of the default one for sale orders and customer invoices"), 'property_supplier_payment_term': fields.property( - 'account.payment.term', type='many2one', relation='account.payment.term', string ='Supplier Payment Term', - view_load=True, help="This payment term will be used instead of the default one for purchase orders and supplier invoices"), 'ref_companies': fields.one2many('res.company', 'partner_id', 'Companies that refers to partner'), diff --git a/addons/account/product.py b/addons/account/product.py index 3df3ad9bd17..b7bffee43a9 100644 --- a/addons/account/product.py +++ b/addons/account/product.py @@ -25,18 +25,14 @@ class product_category(osv.osv): _inherit = "product.category" _columns = { 'property_account_income_categ': fields.property( - 'account.account', type='many2one', relation='account.account', string="Income Account", - view_load=True, help="This account will be used for invoices to value sales."), 'property_account_expense_categ': fields.property( - 'account.account', type='many2one', relation='account.account', string="Expense Account", - view_load=True, help="This account will be used for invoices to value expenses."), } @@ -54,18 +50,14 @@ class product_template(osv.osv): 'product_supplier_taxes_rel', 'prod_id', 'tax_id', 'Supplier Taxes', domain=[('parent_id', '=', False),('type_tax_use','in',['purchase','all'])]), 'property_account_income': fields.property( - 'account.account', type='many2one', relation='account.account', string="Income Account", - view_load=True, help="This account will be used for invoices instead of the default one to value sales for the current product."), 'property_account_expense': fields.property( - 'account.account', type='many2one', relation='account.account', string="Expense Account", - view_load=True, help="This account will be used for invoices instead of the default one to value expenses for the current product."), } diff --git a/addons/account_anglo_saxon/__openerp__.py b/addons/account_anglo_saxon/__openerp__.py index 7ac4bdbd71e..4fc15bba4f5 100644 --- a/addons/account_anglo_saxon/__openerp__.py +++ b/addons/account_anglo_saxon/__openerp__.py @@ -44,7 +44,7 @@ account.""", 'category': 'Accounting & Finance', 'demo': [], 'data': ['product_view.xml'], - 'test': ['test/anglo_saxon.yml'], + 'test': ['test/anglo_saxon.yml', 'test/anglo_saxon_avg_fifo.yml'], 'auto_install': False, 'installable': True, } diff --git a/addons/account_anglo_saxon/invoice.py b/addons/account_anglo_saxon/invoice.py index f27d9b3ae72..8b31a48b92b 100644 --- a/addons/account_anglo_saxon/invoice.py +++ b/addons/account_anglo_saxon/invoice.py @@ -117,21 +117,27 @@ class account_invoice_line(osv.osv): for line in res: if a == line['account_id'] and i_line.product_id.id == line['product_id']: uom = i_line.product_id.uos_id or i_line.product_id.uom_id - standard_price = self.pool.get('product.uom')._compute_price(cr, uid, uom.id, i_line.product_id.standard_price, i_line.uos_id.id) - if standard_price != i_line.price_unit and line['price_unit'] == i_line.price_unit and acc: - price_diff = i_line.price_unit - standard_price - line.update({'price':standard_price * line['quantity']}) + valuation_price_unit = self.pool.get('product.uom')._compute_price(cr, uid, uom.id, i_line.product_id.standard_price, i_line.uos_id.id) + if i_line.product_id.cost_method != 'standard' and i_line.purchase_line_id: + #for average/fifo/lifo costing method, fetch real cost price from incomming moves + stock_move_obj = self.pool.get('stock.move') + valuation_stock_move = stock_move_obj.search(cr, uid, [('purchase_line_id', '=', i_line.purchase_line_id.id)], limit=1, context=context) + if valuation_stock_move: + valuation_price_unit = stock_move_obj.browse(cr, uid, valuation_stock_move[0], context=context).price_unit + if valuation_price_unit != i_line.price_unit and line['price_unit'] == i_line.price_unit and acc: + price_diff = i_line.price_unit - valuation_price_unit + line.update({'price': valuation_price_unit * line['quantity']}) diff_res.append({ - 'type':'src', + 'type': 'src', 'name': i_line.name[:64], - 'price_unit':price_diff, - 'quantity':line['quantity'], + 'price_unit': price_diff, + 'quantity': line['quantity'], 'price': price_diff * line['quantity'], - 'account_id':acc, - 'product_id':line['product_id'], - 'uos_id':line['uos_id'], - 'account_analytic_id':line['account_analytic_id'], - 'taxes':line.get('taxes',[]), + 'account_id': acc, + 'product_id': line['product_id'], + 'uos_id': line['uos_id'], + 'account_analytic_id': line['account_analytic_id'], + 'taxes': line.get('taxes', []), }) res += diff_res return res diff --git a/addons/account_anglo_saxon/product.py b/addons/account_anglo_saxon/product.py index b52d9ed3bbd..1c9e8ee3673 100644 --- a/addons/account_anglo_saxon/product.py +++ b/addons/account_anglo_saxon/product.py @@ -24,27 +24,21 @@ class product_category(osv.osv): _inherit = "product.category" _columns = { 'property_account_creditor_price_difference_categ': fields.property( - 'account.account', type='many2one', relation='account.account', string="Price Difference Account", - view_load=True, help="This account will be used to value price difference between purchase price and cost price."), #Redefine fields to change help text for anglo saxon methodology. 'property_account_income_categ': fields.property( - 'account.account', type='many2one', relation='account.account', string="Income Account", - view_load=True, help="This account will be used to value outgoing stock using sale price."), 'property_account_expense_categ': fields.property( - 'account.account', type='many2one', relation='account.account', string="Expense Account", - view_load=True, help="This account will be used to value outgoing stock using cost price."), } @@ -53,27 +47,21 @@ class product_template(osv.osv): _inherit = "product.template" _columns = { 'property_account_creditor_price_difference': fields.property( - 'account.account', type='many2one', relation='account.account', string="Price Difference Account", - view_load=True, help="This account will be used to value price difference between purchase price and cost price."), #Redefine fields to change help text for anglo saxon methodology. 'property_account_income': fields.property( - 'account.account', type='many2one', relation='account.account', string="Income Account", - view_load=True, help="This account will be used to value outgoing stock using sale price."), 'property_account_expense': fields.property( - 'account.account', type='many2one', relation='account.account', string="Expense Account", - view_load=True, help="This account will be used to value outgoing stock using cost price."), } diff --git a/addons/account_anglo_saxon/purchase.py b/addons/account_anglo_saxon/purchase.py index c10a2a97d80..fc36dab41c2 100644 --- a/addons/account_anglo_saxon/purchase.py +++ b/addons/account_anglo_saxon/purchase.py @@ -26,16 +26,15 @@ class purchase_order(osv.osv): _inherit = "purchase.order" _description = "Purchase Order" - def _prepare_inv_line(self, cr, uid, account_id, order_line, context=None): - line = super(purchase_order, self)._prepare_inv_line(cr, uid, account_id, order_line, context=context) + def _choose_account_from_po_line(self, cr, uid, order_line, context=None): + account_id = super(purchase_order, self)._choose_account_from_po_line(cr, uid, order_line, context=context) if order_line.product_id and not order_line.product_id.type == 'service': acc_id = order_line.product_id.property_stock_account_input and order_line.product_id.property_stock_account_input.id if not acc_id: acc_id = order_line.product_id.categ_id.property_stock_account_input_categ and order_line.product_id.categ_id.property_stock_account_input_categ.id if acc_id: fpos = order_line.order_id.fiscal_position or False - new_account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, acc_id) - line.update({'account_id': new_account_id}) - return line + account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, acc_id) + return account_id # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_anglo_saxon/test/anglo_saxon.yml b/addons/account_anglo_saxon/test/anglo_saxon.yml index 9e46aa52b12..6e9ebc0068e 100644 --- a/addons/account_anglo_saxon/test/anglo_saxon.yml +++ b/addons/account_anglo_saxon/test/anglo_saxon.yml @@ -109,7 +109,7 @@ - !record {model: purchase.order, id: purchase_order_001}: partner_id: base.res_partner_3 - location_id: stock.stock_location_3 + location_id: stock.stock_location_stock pricelist_id: 1 order_line: - product_id: product.product_product_3 @@ -128,12 +128,12 @@ partial_id = self.create(cr, uid, {},context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]}) self.do_partial(cr, uid, [partial_id]) - - I check the Stock Interim account (Received) is credit successfully. + I check the Stock Interim account (Received) is credited successfully. - !assert {model: account.account, id : account_anglo_stock_input, string : Stock Interim account (Received) is not credited successfully.}: - credit == 9 - - I check the Stock valuation account is debit sucessfully. + I check the Stock valuation account is debited sucessfully. - !assert {model: account.account, id : account_anglo_stock_valuation, string : Stock valuation account is not debited successfully.}: - debit == 9 @@ -192,7 +192,7 @@ invoice_state: 2binvoiced move_lines: - company_id: base.main_company - location_id: stock.stock_location_3 + location_id: stock.stock_location_stock product_id: product.product_product_3 product_qty: 1.0 product_uom: product.product_uom_unit diff --git a/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml b/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml new file mode 100644 index 00000000000..f7d52f4f5a8 --- /dev/null +++ b/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml @@ -0,0 +1,304 @@ +- + In order to test anglo_saxon Configure Different Accounts. +- + !record {model: account.account, id: account_anglo_stock_valuation_fifo}: + code: X3000f + name: Stock Valuation Account- (test) + parent_id: account.cas + type: other + user_type: account.data_account_type_asset +- + Configure Stock Interim account (Received). +- + !record {model: account.account, id: account_anglo_stock_input_fifo}: + code: X2800f + name: Stock Interim account (Received) + parent_id: account.cos + type: other + user_type: account.data_account_type_expense +- + Configure Stock Interim account (Delivered). +- + !record {model: account.account, id: account_anglo_stock_output_fifo}: + code: X2801f + name: Stock Interim account (Delivered) + parent_id: account.rev + type: other + user_type: account.data_account_type_income +- + Configure Price difference creditor Account. +- + !record {model: account.account, id: account_anglo_price_difference_fifo}: + code: X7095f + name: Price difference creditor Account + parent_id: account.cos + type: other + user_type: account.data_account_type_expense +- + Configure Cash Bank Account. +- + !record {model: account.account, id: account_anglo_cash_fifo}: + code: X5000f + name: Cash/Bank Account + parent_id: account.cash + type: other + user_type: account.data_account_type_asset +- + Configure Creditor Account Payable. +- + !record {model: account.account, id: account_anglo_payable_fifo}: + code: X440001f + name: Creditor Account Payable + parent_id: account.a_pay + type: other + user_type: account.data_account_type_payable +- + Configure Debtor Account Receivable. +- + !record {model: account.account, id: account_anglo_receivable_fifo}: + code: X400001f + name: Debtor Account Receivable + parent_id: account.a_recv + type: other + user_type: account.data_account_type_receivable +- + Configure Cost of Good sale Account. +- + !record {model: account.account, id: account_anglo_cogs_fifo}: + code: X7000f + name: Cost of goods sale account + parent_id: account.o_expense + type: other + user_type: account.data_account_type_expense +- + Configure Income Account. +- + !record {model: account.account, id: account_anglo_income_fifo}: + code: X8000f + name: Income Account + parent_id: account.o_income + type: other + user_type: account.data_account_type_income +- + I configure the account receivable of supplier +- + !record {model: res.partner, id: base.res_partner_3}: + property_account_payable: account_anglo_payable_fifo + property_account_receivable: account_anglo_receivable_fifo +- + I configure the account receivable of Customer. +- + !record {model: res.partner, id: base.res_partner_13}: + property_account_payable: account_anglo_payable_fifo + property_account_receivable: account_anglo_receivable_fifo +- + I configure the product category with stock valuation account. +- + !record {model: product.category, id: product.product_category_4}: + property_stock_valuation_account_id: account_anglo_stock_valuation_fifo +- + I create a product with required accounts, and cost method average (but same applies for fifo) +- + !record {model: product.product, id: product_fifo_anglo_saxon}: + name: 'FIFO product for anglo saxon tests' + list_price: 20.00 + standard_price: 0 + categ_id: product.product_category_4 + valuation: 'real_time' + property_account_income: account_anglo_income_fifo + property_account_expense: account_anglo_cogs_fifo + property_account_creditor_price_difference: account_anglo_price_difference_fifo + property_stock_account_input: account_anglo_stock_input_fifo + property_stock_account_output: account_anglo_stock_output_fifo + cost_method: 'average' +- + I create a draft Purchase Order. +- + !record {model: purchase.order, id: purchase_order_001_fifo}: + partner_id: base.res_partner_3 + location_id: stock.stock_location_stock + pricelist_id: 1 + order_line: + - product_id: product_fifo_anglo_saxon + product_qty: 1 + price_unit: 9 + date_planned: '2013-08-31' + taxes_id: [] +- + I confirm the purchase order. +- + !workflow {model: purchase.order, ref: purchase_order_001_fifo, action: purchase_confirm} +- + Reception is ready for process so now done the reception. +- + !python {model: stock.partial.picking}: | + pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001_fifo")).picking_ids + partial_id = self.create(cr, uid, {},context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]}) + self.do_partial(cr, uid, [partial_id]) +- + I check the Stock Interim account (Received) is credit successfully. +- + !assert {model: account.account, id : account_anglo_stock_input_fifo, string : Stock Interim account (Received) is not credited successfully.}: + - credit == 9 +- + I check the Stock valuation account is debit sucessfully. +- + !assert {model: account.account, id : account_anglo_stock_valuation_fifo, string : Stock valuation account is not debited successfully.}: + - debit == 9 +- + I Validate Invoice of Purchase Order after having changed the price to 10. +- + !python {model: purchase.order}: | + invoice_ids = [x.id for x in self.browse(cr, uid, ref("purchase_order_001_fifo")).invoice_ids] + line_ids = self.pool.get('account.invoice.line').search(cr, uid, [('invoice_id', 'in', invoice_ids)]) + self.pool.get('account.invoice.line').write(cr, uid, line_ids, {'price_unit': 10}) + self.pool.get('account.invoice').signal_invoice_open(cr, uid, invoice_ids) +- + I check the Stock Interim account (Received) is debited sucessfully when Invoice validated. +- + !assert {model: account.account, id : account_anglo_stock_input_fifo, string : Stock Interim account (Received) is not debited successfully.}: + - debit == 9 +- + I check the Price difference creditor Account is debited sucessfully when Invoice validated. +- + !assert {model: account.account, id : account_anglo_price_difference_fifo, string : Price difference creditor Account is not debited successfully.}: + - debit == 1 +- + I check Payable(creditor) Account is Credited sucessfully when Invoice validated. +- + !assert {model: account.account, id : account_anglo_payable_fifo, string : Payable(creditor) Account is not Credited successfully.}: + - credit == 10 +- + I pay the invoice. +- + !python {model: purchase.order}: | + invoice_ids = self.browse(cr, uid, ref("purchase_order_001_fifo")).invoice_ids + order = self.browse(cr, uid, ref("purchase_order_001_fifo")) + journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', order.company_id.id)], limit=1) + for invoice in invoice_ids: + invoice.pay_and_reconcile(invoice.amount_total, ref('account_anglo_cash_fifo'), ref('account.period_8'), journal_ids[0], ref('account_anglo_cash_fifo'), ref('account.period_8'), journal_ids[0], name='test') +- + I check Payable(Creditors) Account is Debited sucessfully after invoice paid. +- + !assert {model: account.account, id : account_anglo_payable_fifo, string : Payable(Creditors) Account is not Debited successfully.}: + - debit == 10 +- + I check Bank/Cash account is credited sucessfully after invoice paid. +- + !assert {model: account.account, id : account_anglo_cash_fifo, string: Bank/Cash account is not credited successfully.}: + - credit == 10 +- + I create an Outgoing Picking order +- + !record {model: stock.picking, id: stock_picking_out001_fifo}: + partner_id: base.res_partner_13 + invoice_state: 2binvoiced + move_lines: + - company_id: base.main_company + location_id: stock.stock_location_stock + product_id: product_fifo_anglo_saxon + product_qty: 1.0 + location_dest_id: stock.stock_location_customers + move_type: direct + type: out +- + I need to check the availability of the product, So I make my picking order for processing later. +- + !python {model: stock.picking}: | + self.draft_force_assign(cr, uid, [ref("stock_picking_out001_fifo")], {"lang": "en_US", "search_default_available": + 1, "tz": False, "active_model": "ir.ui.menu", "contact_display": "partner", + "active_ids": [ref("stock.menu_action_picking_tree")], "active_id": ref("stock.menu_action_picking_tree"), + }) +- + I check the product availability, Product is available in the stock and ready to be sent. +- + !python {model: stock.picking}: | + self.action_assign(cr, uid, [ref("stock_picking_out001_fifo")], {"lang": "en_US", "search_default_available": + 1, "tz": False, "active_model": "ir.ui.menu", "contact_display": "partner", + "active_ids": [ref("stock.menu_action_picking_tree")], "active_id": ref("stock.menu_action_picking_tree"), + }) +- + I process the delivery. +- + !python {model: stock.partial.picking}: | + partial_id = self.create(cr, uid, {}, context={'active_model':'stock.picking','active_ids':[ref('stock_picking_out001_fifo')]}) + self.do_partial(cr, uid, [partial_id]) +- + I check Stock Interim account (Delivery) is debited successfully. +- + !assert {model: account.account, id : account_anglo_stock_output_fifo, string : Stock Interim account (Delivery) is not debited successfully.}: + - debit == 9 +- + I check the Stock valuation account is credited sucessfully. +- + !assert {model: account.account, id : account_anglo_stock_valuation_fifo, string : Stock valuation account is not credited successfully.}: + - credit == 9 +- + As the Invoice state of the picking order is To be invoiced. I create invoice for my outgoing picking order. +- + !python {model: stock.invoice.onshipping}: | + wiz_id = self.create(cr, uid, {'invoice_date': '2013-03-04', 'journal_id': ref('account.sales_journal')}, + {'active_ids': [ref("stock_picking_out001_fifo")], "active_model": "stock.picking"}) + self.create_invoice(cr, uid, [wiz_id], {"lang": "en_US", + "search_default_available": 1, "tz": False, "active_model": "stock.picking", + "contact_display": "partner", "active_ids": [ref("stock_picking_out001_fifo")], "active_id": ref("stock_picking_out001_fifo")}) +- + I check that the customer invoice is created successfully. +- + !python {model: account.invoice}: | + partner_id = self.pool.get('stock.picking').browse(cr, uid, ref('stock_picking_out001_fifo')).partner_id.id + inv_ids = self.search(cr, uid, [('type','=','out_invoice'),('partner_id','=',partner_id)]) + assert inv_ids, 'No Invoice is generated!' +- + I open the Invoice. +- + !python {model: stock.picking}: | + move_name = self.pool.get('stock.picking').browse(cr, uid, ref('stock_picking_out001_fifo')).name + account_invoice = self.pool.get('account.invoice').search(cr, uid, [('origin', '=', move_name)]) + account_invoice_line = self.pool.get('account.invoice.line').search(cr, uid, [('invoice_id', 'in', account_invoice)]) + self.pool.get('account.invoice.line').write(cr, uid, account_invoice_line, {'invoice_line_tax_id': [(6, 0, [])]}) + self.pool.get('account.invoice').button_reset_taxes(cr, uid, account_invoice) + self.pool.get('account.invoice').signal_invoice_open(cr, uid, account_invoice) +- + I check Income Account is Credited sucessfully when Invoice validated. +- + !assert {model: account.account, id : account_anglo_income_fifo, string : Income Account is not Credited successfully.}: + - credit == 20 +- + I check Cost of goods sold account for debit. +- + !assert {model: account.account, id : account_anglo_cogs_fifo, string : Cost of goods sale is not Debited successfully.}: + - debit == 9 +- + I check Stock Interim account (Delivery) +- + !assert {model: account.account, id : account_anglo_stock_output_fifo, string : Stock Interim account (Delivery) is not credited successfully.}: + - credit == 9 +- + I check Receivable(Debtor) Account for debit. +- + !assert {model: account.account, id : account_anglo_receivable_fifo, string : Receivable(Debtors) Account is not Debited successfully.}: + - debit == 20 +- + I pay the invoice. +- + !python {model: account.invoice}: | + move_name = self.pool.get('stock.picking').browse(cr, uid, ref('stock_picking_out001_fifo')).name + account_invoice= self.pool.get('account.invoice').search(cr, uid, [('origin', '=', move_name)]) + journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash')], limit=1) + pay = self.pay_and_reconcile(cr, uid, account_invoice, + 20.0, ref('account_anglo_cash_fifo'), ref('account.period_8'), + journal_ids[0], ref('account_anglo_cash_fifo'), + ref('account.period_8'), journal_ids[0], + name='Payment for test customer invoice') + assert (pay == True), "Incorrect Payment." +- + I check Receivable(Debtor) Account for credit. +- + !assert {model: account.account, id : account_anglo_receivable_fifo, string : Receivable(Debtors) Account is not Credited successfully.}: + - credit == 20 +- + I check Bank/Cash account is debited sucessfully after invoice paid. +- + !assert {model: account.account, id : account_anglo_cash_fifo, string: Bank/Cash account is not successfully credited.}: + - debit == 20 diff --git a/addons/auth_oauth/controllers/main.py b/addons/auth_oauth/controllers/main.py index 62eb2e812cc..35a06871696 100644 --- a/addons/auth_oauth/controllers/main.py +++ b/addons/auth_oauth/controllers/main.py @@ -7,7 +7,8 @@ from werkzeug.exceptions import BadRequest import openerp from openerp import SUPERUSER_ID -import openerp.addons.web.http as oeweb +import openerp.addons.web.http as http +from openerp.addons.web.http import request from openerp.addons.web.controllers.main import db_monodb, set_cookie_and_redirect, login_and_redirect from openerp.modules.registry import RegistryManager @@ -18,7 +19,7 @@ _logger = logging.getLogger(__name__) #---------------------------------------------------------- def fragment_to_query_string(func): @functools.wraps(func) - def wrapper(self, req, **kw): + def wrapper(self, **kw): if not kw: return """""" - return func(self, req, **kw) + return func(self, **kw) return wrapper #---------------------------------------------------------- # Controller #---------------------------------------------------------- -class OAuthController(oeweb.Controller): - _cp_path = '/auth_oauth' +class OAuthController(http.Controller): - @oeweb.jsonrequest - def list_providers(self, req, dbname): + @http.route('/auth_oauth/list_providers', type='json', auth='none') + def list_providers(self, dbname): try: registry = RegistryManager.get(dbname) with registry.cursor() as cr: @@ -51,9 +51,9 @@ class OAuthController(oeweb.Controller): l = [] return l - @oeweb.httprequest + @http.route('/auth_oauth/signin', type='http', auth='none') @fragment_to_query_string - def signin(self, req, **kw): + def signin(self, **kw): state = simplejson.loads(kw['state']) dbname = state['d'] provider = state['p'] @@ -71,7 +71,7 @@ class OAuthController(oeweb.Controller): url = '/#action=%s' % action elif menu: url = '/#menu_id=%s' % menu - return login_and_redirect(req, *credentials, redirect_url=url) + return login_and_redirect(*credentials, redirect_url=url) except AttributeError: # auth_signup is not installed _logger.error("auth_signup not installed on database %s: oauth sign up cancelled." % (dbname,)) @@ -88,14 +88,14 @@ class OAuthController(oeweb.Controller): _logger.exception("OAuth2: %s" % str(e)) url = "/#action=login&oauth_error=2" - return set_cookie_and_redirect(req, url) + return set_cookie_and_redirect(url) - @oeweb.httprequest - def oea(self, req, **kw): + @http.route('/auth_oauth/oea', type='http', auth='none') + def oea(self, **kw): """login user via OpenERP Account provider""" dbname = kw.pop('db', None) if not dbname: - dbname = db_monodb(req) + dbname = db_monodb() if not dbname: return BadRequest() @@ -105,7 +105,7 @@ class OAuthController(oeweb.Controller): try: model, provider_id = IMD.get_object_reference(cr, SUPERUSER_ID, 'auth_oauth', 'provider_openerp') except ValueError: - return set_cookie_and_redirect(req, '/?db=%s' % dbname) + return set_cookie_and_redirect('/?db=%s' % dbname) assert model == 'auth.oauth.provider' state = { @@ -115,6 +115,6 @@ class OAuthController(oeweb.Controller): } kw['state'] = simplejson.dumps(state) - return self.signin(req, **kw) + return self.signin(**kw) # vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_signup/controllers/main.py b/addons/auth_signup/controllers/main.py index 924e1546862..8c61af1f03c 100644 --- a/addons/auth_signup/controllers/main.py +++ b/addons/auth_signup/controllers/main.py @@ -23,14 +23,15 @@ import logging import openerp from openerp.modules.registry import RegistryManager from ..res_users import SignupError +import openerp.addons.web.http as http +from openerp.addons.web.http import request _logger = logging.getLogger(__name__) -class Controller(openerp.addons.web.http.Controller): - _cp_path = '/auth_signup' +class Controller(http.Controller): - @openerp.addons.web.http.jsonrequest - def get_config(self, req, dbname): + @http.route('/auth_signup/get_config', type='json', auth="none") + def get_config(self, dbname): """ retrieve the module config (which features are enabled) for the login page """ registry = RegistryManager.get(dbname) with registry.cursor() as cr: @@ -41,8 +42,8 @@ class Controller(openerp.addons.web.http.Controller): } return config - @openerp.addons.web.http.jsonrequest - def retrieve(self, req, dbname, token): + @http.route('/auth_signup/retrieve', type='json', auth="user") + def retrieve(self, dbname, token): """ retrieve the user info (name, login or email) corresponding to a signup token """ registry = RegistryManager.get(dbname) with registry.cursor() as cr: @@ -50,23 +51,23 @@ class Controller(openerp.addons.web.http.Controller): user_info = res_partner.signup_retrieve_info(cr, openerp.SUPERUSER_ID, token) return user_info - @openerp.addons.web.http.jsonrequest - def signup(self, req, dbname, token, **values): + @http.route('/auth_signup/signup', type='json', auth="user") + def signup(self, dbname, token, **values): """ sign up a user (new or existing)""" try: - self._signup_with_values(req, dbname, token, values) + self._signup_with_values(dbname, token, values) except SignupError, e: return {'error': openerp.tools.exception_to_unicode(e)} return {} - def _signup_with_values(self, req, dbname, token, values): + def _signup_with_values(self, dbname, token, values): registry = RegistryManager.get(dbname) with registry.cursor() as cr: res_users = registry.get('res.users') res_users.signup(cr, openerp.SUPERUSER_ID, values, token) - @openerp.addons.web.http.jsonrequest - def reset_password(self, req, dbname, login): + @http.route('/auth_signup/reset_password', type='json', auth="user") + def reset_password(self, dbname, login): """ retrieve user, and perform reset password """ registry = RegistryManager.get(dbname) with registry.cursor() as cr: diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index b8673e73927..44ada2ffcc0 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -719,7 +719,6 @@ class crm_lead(base_stage, format_address, osv.osv): continue vals = self._convert_opportunity_data(cr, uid, lead, customer, section_id, context=context) self.write(cr, uid, [lead.id], vals, context=context) - self.message_post(cr, uid, ids, body=_("Lead converted into an Opportunity"), subtype="crm.mt_lead_convert_to_opportunity", context=context) if user_ids or section_id: self.allocate_salesman(cr, uid, ids, user_ids, section_id, context=context) diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index 0979a94eb3f..92914542d9d 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -163,12 +163,6 @@ Opportunity created - - Lead to Opportunity - crm.lead - - Lead converted into an opportunity - Stage Changed crm.lead @@ -195,13 +189,6 @@ section_id - - Lead to Opportunity - - crm.case.section - - section_id - Opportunity Stage Changed crm.case.section diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 6ddd06c1c90..df6a4a07a8e 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -601,7 +601,9 @@ 'default_email_to':'{$object.email or \'\'}', 'default_use_template': True, 'default_template_id': ref('crm.email_template_opportunity_mail'), - }"/> + }" + groups="base.group_sale_salesman" + /> @@ -617,6 +619,7 @@ if context.get('active_model') == 'crm.lead' and context.get('active_ids'): self.case_cancel(cr, uid, context['active_ids'], context=context) + diff --git a/addons/crm/i18n/hu.po b/addons/crm/i18n/hu.po index 98313efb4f3..6673d2da235 100644 --- a/addons/crm/i18n/hu.po +++ b/addons/crm/i18n/hu.po @@ -7,14 +7,14 @@ msgstr "" "Project-Id-Version: OpenERP Server 6.0dev\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2012-12-21 17:04+0000\n" -"PO-Revision-Date: 2013-04-13 08:42+0000\n" +"PO-Revision-Date: 2013-06-21 07:11+0000\n" "Last-Translator: krnkris \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-04-14 05:12+0000\n" -"X-Generator: Launchpad (build 16564)\n" +"X-Launchpad-Export-Date: 2013-06-22 05:36+0000\n" +"X-Generator: Launchpad (build 16677)\n" #. module: crm #: view:crm.lead.report:0 @@ -31,7 +31,7 @@ msgstr "" "létrehozását a bejövő levelekből." #. module: crm -#: code:addons/crm/crm_lead.py:881 +#: code:addons/crm/crm_lead.py:898 #: selection:crm.case.stage,type:0 #: view:crm.lead:0 #: selection:crm.lead,type:0 @@ -192,8 +192,8 @@ msgstr "" "direkt HTML formátumú ahhoz hogy beilleszthető legyen a kanban nézetekbe." #. module: crm -#: code:addons/crm/crm_lead.py:624 -#: code:addons/crm/crm_lead.py:744 +#: code:addons/crm/crm_lead.py:640 +#: code:addons/crm/crm_lead.py:761 #: code:addons/crm/crm_phonecall.py:280 #, python-format msgid "Warning!" @@ -304,7 +304,7 @@ msgid "Prospect Partner" msgstr "Leendő partner" #. module: crm -#: code:addons/crm/crm_lead.py:982 +#: code:addons/crm/crm_lead.py:1002 #, python-format msgid "No Subject" msgstr "Nincs tárgy" @@ -482,7 +482,7 @@ msgid "#Opportunities" msgstr "Lehetőségek száma" #. module: crm -#: code:addons/crm/crm_lead.py:624 +#: code:addons/crm/crm_lead.py:640 #, python-format msgid "" "Please select more than one element (lead or opportunity) from the list view." @@ -782,7 +782,7 @@ msgid "Statistics Dashboard" msgstr "Statisztika vezérlőpult" #. module: crm -#: code:addons/crm/crm_lead.py:861 +#: code:addons/crm/crm_lead.py:878 #: model:crm.case.stage,name:crm.stage_lead2 #: selection:crm.case.stage,type:0 #: view:crm.lead:0 @@ -844,7 +844,7 @@ msgid "Exclusive" msgstr "Kizárólagos" #. module: crm -#: code:addons/crm/crm_lead.py:584 +#: code:addons/crm/crm_lead.py:600 #, python-format msgid "From %s : %s" msgstr "Ettől %s : %s" @@ -1016,7 +1016,7 @@ msgid "Next Action" msgstr "Következő művelet" #. module: crm -#: code:addons/crm/crm_lead.py:763 +#: code:addons/crm/crm_lead.py:780 #, python-format msgid "Partner set to %s." msgstr "Partner beállítva mint %s." @@ -1109,7 +1109,7 @@ msgid "Creation Date" msgstr "Létrehozás dátuma" #. module: crm -#: code:addons/crm/crm_lead.py:698 +#: code:addons/crm/crm_lead.py:715 #, python-format msgid "Lead converted into an Opportunity" msgstr "Tervezet lehetőséggé átalakítva lehetőséggé" @@ -1324,7 +1324,9 @@ msgid "Days to Close" msgstr "Lezárásig hátralévő napok" #. module: crm +#: code:addons/crm/crm_lead.py:1057 #: field:crm.case.section,complete_name:0 +#, python-format msgid "unknown" msgstr "Ismeretlen" @@ -1415,7 +1417,7 @@ msgid "Lead Description" msgstr "Érdeklődés leírása" #. module: crm -#: code:addons/crm/crm_lead.py:565 +#: code:addons/crm/crm_lead.py:581 #, python-format msgid "Merged opportunities" msgstr "Lehetőségek összefésülése" @@ -1989,7 +1991,7 @@ msgid "Leads" msgstr "Érdeklődők" #. module: crm -#: code:addons/crm/crm_lead.py:563 +#: code:addons/crm/crm_lead.py:579 #, python-format msgid "Merged leads" msgstr "Össztefésült érdeklődések" @@ -2085,7 +2087,6 @@ msgid "Global CC" msgstr "Globális CC /másolat/" #. module: crm -#: view:crm.lead:0 #: view:crm.phonecall:0 #: model:ir.actions.act_window,name:crm.crm_case_categ_phone0 #: model:ir.ui.menu,name:crm.menu_crm_case_phone @@ -2399,7 +2400,7 @@ msgstr "Érdeklődés átalakítva egy lehetőséggé" #. module: crm #: view:crm.lead:0 msgid "Unassigned Leads" -msgstr "Nem iktatott rdeklődések" +msgstr "Nem iktatott érdeklődések" #. module: crm #: model:mail.message.subtype,description:crm.mt_lead_won @@ -3100,7 +3101,7 @@ msgid "Working Hours" msgstr "Munkaórák" #. module: crm -#: code:addons/crm/crm_lead.py:968 +#: code:addons/crm/crm_lead.py:986 #: view:crm.lead:0 #: field:crm.lead2opportunity.partner,partner_id:0 #: field:crm.lead2opportunity.partner.mass,partner_id:0 diff --git a/addons/crm/wizard/crm_lead_to_opportunity_view.xml b/addons/crm/wizard/crm_lead_to_opportunity_view.xml index 4093df910d0..9ddd1fc701f 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity_view.xml +++ b/addons/crm/wizard/crm_lead_to_opportunity_view.xml @@ -102,7 +102,9 @@ res_model="crm.lead2opportunity.partner.mass" src_model="crm.lead" view_mode="form" target="new" view_type="form" context="{'mass_convert' : True}" - view_id="view_crm_lead2opportunity_partner_mass"/> + view_id="view_crm_lead2opportunity_partner_mass" + groups="base.group_sale_salesman" + /> diff --git a/addons/crm/wizard/crm_merge_opportunities_view.xml b/addons/crm/wizard/crm_merge_opportunities_view.xml index 919d83cb9a7..60693c13e19 100644 --- a/addons/crm/wizard/crm_merge_opportunities_view.xml +++ b/addons/crm/wizard/crm_merge_opportunities_view.xml @@ -45,7 +45,9 @@ multi="True" key2="client_action_multi" name="Merge leads/opportunities" res_model="crm.merge.opportunity" src_model="crm.lead" - view_mode="form" target="new" view_type="form"/> + view_mode="form" target="new" view_type="form" + groups="base.group_sale_salesman" + /> diff --git a/addons/crm_partner_assign/__init__.py b/addons/crm_partner_assign/__init__.py index bb4a3bb53be..6b1315cef07 100644 --- a/addons/crm_partner_assign/__init__.py +++ b/addons/crm_partner_assign/__init__.py @@ -20,6 +20,7 @@ ############################################################################## import crm_partner_assign +import crm_lead import wizard import report diff --git a/addons/crm_partner_assign/__openerp__.py b/addons/crm_partner_assign/__openerp__.py index b9b21ca7a6a..37a8c5a3d6b 100644 --- a/addons/crm_partner_assign/__openerp__.py +++ b/addons/crm_partner_assign/__openerp__.py @@ -37,17 +37,23 @@ The most appropriate partner can be assigned. You can also use the geolocalization without using the GPS coordinates. """, 'author': 'OpenERP SA', - 'depends': ['crm', 'account'], + 'depends': ['crm', 'account', 'portal'], 'demo': ['res_partner_demo.xml'], 'data': [ 'security/ir.model.access.csv', 'res_partner_view.xml', 'wizard/crm_forward_to_partner_view.xml', + 'wizard/crm_channel_interested_view.xml', 'crm_lead_view.xml', 'crm_partner_assign_data.xml', + 'crm_portal_view.xml', + 'portal_data.xml', 'report/crm_lead_report_view.xml', 'report/crm_partner_report_view.xml', ], + 'js': [ + 'static/src/js/next.js', + ], 'test': ['test/partner_assign.yml'], 'installable': True, 'auto_install': False, diff --git a/addons/crm_partner_assign/crm_lead.py b/addons/crm_partner_assign/crm_lead.py new file mode 100644 index 00000000000..37f4b9aedff --- /dev/null +++ b/addons/crm_partner_assign/crm_lead.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import osv +from openerp.tools.translate import _ + + +class crm_lead(osv.osv): + _inherit = 'crm.lead' + + def get_interested_action(self, cr, uid, interested, context=None): + try: + model, action_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm_partner_assign', 'crm_lead_channel_interested_act') + except ValueError: + raise osv.except_osv(_('Error!'), _("The CRM Channel Interested Action is missing")) + action = self.pool[model].read(cr, uid, action_id, context=context) + action_context = eval(action['context']) + action_context['interested'] = interested + action['context'] = str(action_context) + return action + + def case_interested(self, cr, uid, ids, context=None): + return self.get_interested_action(cr, uid, True, context=context) + + def case_disinterested(self, cr, uid, ids, context=None): + return self.get_interested_action(cr, uid, False, context=context) diff --git a/addons/crm_partner_assign/crm_lead_view.xml b/addons/crm_partner_assign/crm_lead_view.xml index 0d2837d6ca5..5c14680ee78 100644 --- a/addons/crm_partner_assign/crm_lead_view.xml +++ b/addons/crm_partner_assign/crm_lead_view.xml @@ -8,27 +8,33 @@ - + - - -