[IMP] sale,purchase: allow invoicing
(closes #500) (cherry picked from commit 84c0595aef3a417702c81b5226ae1f61817a2bf8)
This commit is contained in:
@@ -304,7 +304,7 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_finance_assets" name="Assets" parent="account.menu_finance" sequence="7"/>
|
||||
<menuitem id="menu_finance_assets" name="Assets" parent="account.menu_finance" sequence="7" groups="account.group_account_user"/>
|
||||
<menuitem parent="menu_finance_assets" id="menu_action_account_asset_asset_tree"
|
||||
sequence="100"
|
||||
action="action_account_asset_asset_tree"/>
|
||||
|
||||
@@ -9,3 +9,6 @@ access_account_asset_depreciation_line,account.asset.depreciation.line,model_acc
|
||||
access_account_asset_depreciation_line_manager,account.asset.depreciation.line,model_account_asset_depreciation_line,account.group_account_manager,1,1,1,1
|
||||
access_asset_asset_report,asset.asset.report,model_asset_asset_report,account.group_account_user,1,0,0,0
|
||||
access_asset_asset_report_manager,asset.asset.report,model_asset_asset_report,account.group_account_manager,1,1,1,1
|
||||
access_account_asset_category_invoicing_payment,account.asset.category,model_account_asset_category,account.group_account_invoice,1,0,0,0
|
||||
access_account_asset_asset_invoicing_payment,account.asset.asset,model_account_asset_asset,account.group_account_invoice,1,0,1,0
|
||||
access_account_asset_depreciation_line_invoicing_payment,account.asset.depreciation.line,model_account_asset_depreciation_line,account.group_account_invoice,1,0,1,0
|
||||
|
||||
|
@@ -8,3 +8,4 @@ access_res_partner_grade_manager,res.partner.grade.manager,model_res_partner_gra
|
||||
access_res_partner_activation_user,res.partner.activation.user,model_res_partner_activation,base.group_user,1,0,0,0
|
||||
"access_partner_activation_manager","res.partner.activation.manager","model_res_partner_activation","base.group_partner_manager",1,1,1,1
|
||||
partner_access_crm_lead,crm.lead,model_crm_lead,base.group_portal,1,1,0,0
|
||||
access_res_partner_grade_invoicing_payment,res.partner.grade,model_res_partner_grade,account.group_account_invoice,1,0,0,0
|
||||
|
||||
|
@@ -79,4 +79,6 @@ access_account_journal_mrp_manager,account.journal mrp manager,account.model_acc
|
||||
access_mrp_property_group,mrp.property.group,model_mrp_property_group,stock.group_stock_manager,1,1,1,1
|
||||
access_mrp_property,mrp.property,model_mrp_property,stock.group_stock_manager,1,1,1,1
|
||||
access_mrp_property_group,mrp.property.group,model_mrp_property_group,base.group_user,1,0,0,0
|
||||
access_mrp_property,mrp.property,model_mrp_property,base.group_user,1,0,0,0
|
||||
access_mrp_property,mrp.property,model_mrp_property,base.group_user,1,0,0,0
|
||||
access_mrp_bom_invoicing_payment,mrp.bom,model_mrp_bom,account.group_account_invoice,1,0,0,0
|
||||
access_mrp_production_invoicing_payment,mrp.production,model_mrp_production,account.group_account_invoice,1,1,1,0
|
||||
|
||||
|
@@ -62,3 +62,5 @@ access_stock_warehouse_orderpoint_manager,stock.warehouse.orderpoint,stock.model
|
||||
access_stock_warehouse_orderpoint_manager,stock.warehouse.orderpoint,stock.model_stock_warehouse_orderpoint,group_purchase_user,1,0,0,0
|
||||
access_product_price_history_purchase_user,prices.history purchase user,product.model_product_price_history,purchase.group_purchase_user,1,0,0,0
|
||||
access_product_price_history_purchase_manager,prices.history purchase manager,product.model_product_price_history,purchase.group_purchase_manager,1,1,1,1
|
||||
access_purchase_order_invoicing_payments,purchase.order,model_purchase_order,account.group_account_invoice,1,1,0,0
|
||||
access_purchase_order_line_invoicing_payments,purchase.order.line,model_purchase_order_line,account.group_account_invoice,1,1,0,0
|
||||
|
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Business Applications
|
||||
# Copyright (c) 2013-TODAY OpenERP S.A. <http://www.openerp.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import test_purchase_to_invoice
|
||||
|
||||
checks = [
|
||||
test_purchase_to_invoice,
|
||||
]
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -0,0 +1,93 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Business Applications
|
||||
# Copyright (c) 2013-TODAY OpenERP S.A. <http://www.openerp.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.addons.mail.tests.common import TestMail
|
||||
from openerp.tools import mute_logger
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class TestPurchase(TestMail):
|
||||
@mute_logger('openerp.addons.base.ir.ir_model', 'openerp.osv.orm')
|
||||
|
||||
def setUp(self):
|
||||
super(TestPurchase, self).setUp()
|
||||
|
||||
def test_purchase_to_invoice(self):
|
||||
""" Testing for invoice create,validate and pay with invoicing and payment user."""
|
||||
cr, uid = self.cr, self.uid
|
||||
|
||||
# Usefull models
|
||||
data_obj = self.registry('ir.model.data')
|
||||
user_obj = self.registry('res.users')
|
||||
partner_obj = self.registry('res.partner')
|
||||
purchase_obj = self.registry('purchase.order')
|
||||
purchase_order_line = self.registry('purchase.order.line')
|
||||
invoice_obj = self.registry('account.invoice')
|
||||
|
||||
# Usefull record id
|
||||
group_id = data_obj.get_object_reference(cr, uid, 'account', 'group_account_invoice')[1]
|
||||
product_ref = data_obj.get_object_reference(cr, uid, 'product', 'product_category_5')
|
||||
product_id = product_ref and product_ref[1] or False
|
||||
company_id = data_obj.get_object_reference(cr, uid, 'base', 'main_company')[1]
|
||||
location_id = data_obj.get_object_reference(cr, uid, 'stock', 'stock_location_3')[1]
|
||||
|
||||
# In order to test, I create new user and applied Invoicing & Payments group.
|
||||
user_id = user_obj.create(cr, uid, {
|
||||
'name': 'Test User',
|
||||
'login': 'test@test.com',
|
||||
'company_id': 1,
|
||||
'groups_id': [(6, 0, [group_id])]
|
||||
})
|
||||
assert user_id, "User will not created."
|
||||
|
||||
# I create partner for purchase order.
|
||||
partner_id = partner_obj.create(cr, uid, {
|
||||
'name': 'Test Customer',
|
||||
'email': 'testcustomer@test.com',
|
||||
})
|
||||
|
||||
# In order to test I create purchase order and confirmed it.
|
||||
order_id = purchase_obj.create(cr, uid, {
|
||||
'partner_id': partner_id,
|
||||
'location_id': location_id,
|
||||
'pricelist_id': 1,
|
||||
})
|
||||
order_line = purchase_order_line.create(cr, uid, {
|
||||
'order_id': order_id,
|
||||
'product_id': product_id,
|
||||
'product_qty': 100.0,
|
||||
'product_uom': 1,
|
||||
'price_unit': 89.0,
|
||||
'name': 'Service',
|
||||
'date_planned': '2014-05-31',
|
||||
})
|
||||
assert order_id, "purchase order will not created."
|
||||
|
||||
context = {"active_model": 'purchase.order', "active_ids": [order_id], "active_id":order_id}
|
||||
purchase_obj.wkf_confirm_order(cr, uid, [order_id], context=context)
|
||||
|
||||
# In order to test I create invoice.
|
||||
invoice_id = purchase_obj.action_invoice_create(cr, uid, [order_id], context=context)
|
||||
assert invoice_id,"No any invoice is created for this purchase order"
|
||||
|
||||
# In order to test I validate invoice wihth Test User(invoicing and payment).
|
||||
res = invoice_obj.invoice_validate(cr, uid, [invoice_id], context=context)
|
||||
self.assertTrue(res, 'Invoice will not validated')
|
||||
@@ -44,3 +44,6 @@ access_account_move_line_salesman,account.move.line invoice,account.model_accoun
|
||||
access_product_price_history_salemanager,prices.history sale manager,product.model_product_price_history,base.group_sale_manager,1,1,1,1
|
||||
access_product_price_history_account_user,prices.history account user,product.model_product_price_history,account.group_account_user,1,0,0,0
|
||||
access_product_price_history_sale_use,prices.history sale use,product.model_product_price_history,base.group_sale_salesman,1,0,0,0
|
||||
access_sale_order_invoicing_payments,sale.order,model_sale_order,account.group_account_invoice,1,1,0,0
|
||||
access_sale_order_line_invoicing_payments,sale.order.line,model_sale_order_line,account.group_account_invoice,1,1,0,0
|
||||
access_account_invoice_report_invoicing_payments,account.invoice.report,account.model_account_invoice_report,account.group_account_invoice,1,0,0,0
|
||||
|
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Business Applications
|
||||
# Copyright (c) 2013-TODAY OpenERP S.A. <http://www.openerp.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import test_sale_to_invoice
|
||||
|
||||
checks = [
|
||||
test_sale_to_invoice,
|
||||
]
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -0,0 +1,107 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Business Applications
|
||||
# Copyright (c) 2013-TODAY OpenERP S.A. <http://www.openerp.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.addons.mail.tests.common import TestMail
|
||||
from openerp.tools import mute_logger
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class TestSale(TestMail):
|
||||
@mute_logger('openerp.addons.base.ir.ir_model', 'openerp.osv.orm')
|
||||
|
||||
def setUp(self):
|
||||
super(TestSale, self).setUp()
|
||||
|
||||
def test_sale_to_invoice(self):
|
||||
""" Testing for invoice create,validate and pay with invoicing and payment user."""
|
||||
cr, uid = self.cr, self.uid
|
||||
|
||||
# Usefull models
|
||||
data_obj = self.registry('ir.model.data')
|
||||
user_obj = self.registry('res.users')
|
||||
partner_obj = self.registry('res.partner')
|
||||
sale_obj = self.registry('sale.order')
|
||||
sale_order_line = self.registry('sale.order.line')
|
||||
sale_advance_payment_inv = self.registry('sale.advance.payment.inv')
|
||||
invoice_obj = self.registry('account.invoice')
|
||||
voucher_obj = self.registry('account.voucher')
|
||||
|
||||
# Usefull record id
|
||||
group_id = data_obj.get_object_reference(cr, uid, 'account', 'group_account_invoice')[1]
|
||||
product_ref = data_obj.get_object_reference(cr, uid, 'product', 'product_category_5')
|
||||
product_id = product_ref and product_ref[1] or False
|
||||
account_id = data_obj.get_object_reference(cr, uid, 'account', 'cash')[1]
|
||||
company_id = data_obj.get_object_reference(cr, uid, 'base', 'main_company')[1]
|
||||
journal_id = data_obj.get_object_reference(cr, uid, 'account', 'bank_journal')[1]
|
||||
period_id = data_obj.get_object_reference(cr, uid, 'account', 'period_8')[1]
|
||||
|
||||
# In order to test, I create new user and applied Invoicing & Payments group.
|
||||
user_id = user_obj.create(cr, uid, {
|
||||
'name': 'Test User',
|
||||
'login': 'test@test.com',
|
||||
'company_id': 1,
|
||||
'groups_id': [(6, 0, [group_id])]
|
||||
})
|
||||
assert user_id, "User will not created."
|
||||
|
||||
# I create partner for sale order.
|
||||
partner_id = partner_obj.create(cr, uid, {
|
||||
'name': 'Test Customer',
|
||||
'email': 'testcustomer@test.com',
|
||||
})
|
||||
|
||||
# In order to test I create sale order and confirmed it.
|
||||
order_id = sale_obj.create(cr, uid, {
|
||||
'partner_id': partner_id,
|
||||
'date_order': datetime.today(),
|
||||
})
|
||||
order_line = sale_order_line.create(cr, uid, {
|
||||
'order_id': order_id,
|
||||
'product_id': product_id,
|
||||
})
|
||||
assert order_id, "Sale order will not created."
|
||||
|
||||
context = {"active_model": 'sale.order', "active_ids": [order_id], "active_id":order_id}
|
||||
sale_obj.action_button_confirm(cr, uid, [order_id], context=context)
|
||||
|
||||
# Now I create invoice.
|
||||
pay_id = sale_advance_payment_inv.create(cr, uid, {'advance_payment_method': 'fixed', 'amount': 5})
|
||||
inv = sale_advance_payment_inv.create_invoices(cr, uid, [pay_id], context=context)
|
||||
invoice_ids = sale_obj.browse(cr, uid, order_id).invoice_ids
|
||||
assert invoice_ids,"No any invoice is created for this sale order"
|
||||
|
||||
# Now I validate pay invoice wihth Test User(invoicing and payment).
|
||||
for invoice in invoice_ids:
|
||||
invoice_obj.invoice_validate(cr, uid, [invoice.id], context=context)
|
||||
|
||||
# Now I create and post an account voucher of amount 75.0 for the partner Test Customer.
|
||||
voucher_id = voucher_obj.create(cr, uid, {
|
||||
'account_id': account_id,
|
||||
'amount': 75.0,
|
||||
'company_id': company_id,
|
||||
'journal_id': journal_id,
|
||||
'partner_id': partner_id,
|
||||
'period_id': period_id,
|
||||
'type': 'receipt',
|
||||
})
|
||||
assert voucher_id,"Voucher will not created."
|
||||
voucher = voucher_obj.browse(cr, uid, voucher_id)
|
||||
voucher.signal_workflow('proforma_voucher')
|
||||
@@ -3,3 +3,4 @@ report_layout_category_1,report_layout_category_1,model_sale_layout_category,bas
|
||||
report_layout_category_2,report_layout_category_2,model_sale_layout_category,account.group_account_manager,1,1,1,1
|
||||
report_layout_category_3,report_layout_category_3,model_sale_layout_category,base.group_sale_salesman,1,1,1,O
|
||||
report_layout_category_4,report_layout_category_4,model_sale_layout_category,base.group_sale_salesman_all_leads,1,1,1,0
|
||||
report_layout_category_5,report_layout_category_5,model_sale_layout_category,account.group_account_invoice,1,0,0,0
|
||||
|
||||
|
@@ -75,3 +75,5 @@ access_stock_move_operation_link_user,stock.move.operation.link user,model_stock
|
||||
access_stock_move_operation_link_all,stock.move.operation.link all users,model_stock_move_operation_link,base.group_user,1,0,0,0
|
||||
access_product_price_history_stock_user,prices.history stock user,product.model_product_price_history,stock.group_stock_user,1,0,1,0
|
||||
access_product_price_history_stock_manager,prices.history stock manager,product.model_product_price_history,stock.group_stock_manager,1,1,1,1
|
||||
access_stock_picking_invoicing_payments,stock.picking,model_stock_picking,account.group_account_invoice,1,1,1,0
|
||||
access_stock_move_invoicing_payments,stock.move,model_stock_move,account.group_account_invoice,1,1,1,0
|
||||
|
||||
|
Reference in New Issue
Block a user