Port stock_invoice_try_again to v8
This commit is contained in:
@@ -1,23 +1,3 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Stock Invoice Try Again module for OpenERP
|
||||
# Copyright (C) 2013 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.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/>.
|
||||
#
|
||||
##############################################################################
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import stock
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Stock Invoice Try Again module for OpenERP
|
||||
# Copyright (C) 2013 Akretion (http://www.akretion.com)
|
||||
# Stock Invoice Try Again module for Odoo
|
||||
# Copyright (C) 2013-2015 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@@ -37,9 +37,7 @@ Please contact Alexis de Lattre from Akretion <alexis.delattre@akretion.com> for
|
||||
""",
|
||||
'author': 'Akretion',
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': ['stock_picking_invoice_link'],
|
||||
'depends': ['stock_picking_invoice_link', 'stock_account'],
|
||||
'data': ['stock_view.xml'],
|
||||
'images': [],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Stock Invoice Try Again module for OpenERP
|
||||
# Copyright (C) 2013 Akretion (http://www.akretion.com)
|
||||
# Stock Invoice Try Again module for Odoo
|
||||
# Copyright (C) 2013-2015 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@@ -20,43 +20,26 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm
|
||||
from openerp.tools.translate import _
|
||||
from openerp import models, api, _
|
||||
from openerp.exceptions import Warning as UserError
|
||||
|
||||
|
||||
class stock_picking(orm.Model):
|
||||
class StockPicking(models.Model):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
def revert_to_tobeinvoiced(self, cr, uid, ids, context=None):
|
||||
assert len(ids) == 1, "Only one picking"
|
||||
picking = self.browse(cr, uid, ids[0], context=context)
|
||||
if picking.invoice_state == 'invoiced':
|
||||
if picking.invoice_id:
|
||||
raise orm.except_orm(
|
||||
_('Error:'),
|
||||
_("This picking is linked to the invoice with description '%s'. You should first delete this invoice and try again.")
|
||||
% picking.invoice_id.name)
|
||||
self.write(cr, uid, ids[0], {
|
||||
'invoice_state': '2binvoiced',
|
||||
}, context=context)
|
||||
@api.multi
|
||||
def revert_to_tobeinvoiced(self):
|
||||
self.ensure_one()
|
||||
if self.invoice_state == 'invoiced':
|
||||
if self.invoice_id:
|
||||
raise UserError(_(
|
||||
"This picking is linked to the invoice with "
|
||||
"description '%s'. You should first delete this "
|
||||
"invoice and try again.")
|
||||
% self.invoice_id.name)
|
||||
self.invoice_state = '2binvoiced'
|
||||
else:
|
||||
raise orm.except_orm(
|
||||
_('Error:'),
|
||||
_("You can only do this when the Delivery Order has 'Invoice State' = 'Invoiced'."))
|
||||
raise UserError(_(
|
||||
"You can only do this when the Delivery Order "
|
||||
"has 'Invoice State' = 'Invoiced'."))
|
||||
return True
|
||||
|
||||
|
||||
class stock_picking_out(orm.Model):
|
||||
_inherit = 'stock.picking.out'
|
||||
|
||||
def revert_to_tobeinvoiced(self, cr, uid, ids, context=None):
|
||||
return self.pool['stock.picking'].revert_to_tobeinvoiced(
|
||||
cr, uid, ids, context=context)
|
||||
|
||||
|
||||
class stock_picking_in(orm.Model):
|
||||
_inherit = 'stock.picking.in'
|
||||
|
||||
def revert_to_tobeinvoiced(self, cr, uid, ids, context=None):
|
||||
return self.pool['stock.picking'].revert_to_tobeinvoiced(
|
||||
cr, uid, ids, context=context)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2013 Akretion (http://www.akretion.com/)
|
||||
Copyright (C) 2013-2015 Akretion (http://www.akretion.com/)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
@@ -9,53 +9,12 @@
|
||||
<data>
|
||||
|
||||
|
||||
<record id="view_picking_form" model="ir.ui.view">
|
||||
<record id="view_picking_inherit_form2" model="ir.ui.view">
|
||||
<field name="name">stock_invoice_try_again.view_picking_form</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="inherit_id" ref="stock_account.view_picking_inherit_form2"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="invoice_state" position="attributes">
|
||||
<attribute name="attrs"></attribute>
|
||||
</field>
|
||||
<button string="Create Invoice/Refund" position="after">
|
||||
<button name="revert_to_tobeinvoiced"
|
||||
string="Revert to To be Invoiced"
|
||||
type="object"
|
||||
confirm="Are you sure you want to revert the 'Invoice Control' to 'To be Invoiced' ?"
|
||||
attrs="{'invisible': [('invoice_state', '!=', 'invoiced')]}"
|
||||
groups="account.group_account_invoice" />
|
||||
</button>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_out_form" model="ir.ui.view">
|
||||
<field name="name">stock_invoice_try_again.view_picking_out_form</field>
|
||||
<field name="model">stock.picking.out</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_out_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="invoice_state" position="attributes">
|
||||
<attribute name="attrs"></attribute>
|
||||
</field>
|
||||
<button string="Create Invoice/Refund" position="after">
|
||||
<button name="revert_to_tobeinvoiced"
|
||||
string="Revert to To be Invoiced"
|
||||
type="object"
|
||||
confirm="Are you sure you want to revert the 'Invoice Control' to 'To be Invoiced' ?"
|
||||
attrs="{'invisible': [('invoice_state', '!=', 'invoiced')]}"
|
||||
groups="account.group_account_invoice" />
|
||||
</button>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_in_form" model="ir.ui.view">
|
||||
<field name="name">stock_invoice_try_again.view_picking_in_form</field>
|
||||
<field name="model">stock.picking.in</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_in_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="invoice_state" position="attributes">
|
||||
<attribute name="attrs"></attribute>
|
||||
</field>
|
||||
<button string="Create Invoice/Refund" position="after">
|
||||
<button string="Create Invoice" position="after">
|
||||
<button name="revert_to_tobeinvoiced"
|
||||
string="Revert to To be Invoiced"
|
||||
type="object"
|
||||
|
||||
Reference in New Issue
Block a user