Stop re-developping modules that exists in OCA/sale-workflow !
This commit is contained in:
@@ -1,3 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from . import sale
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2018 Akretion (http://www.akretion.com)
|
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
{
|
|
||||||
'name': 'Sale Force Invoice Status',
|
|
||||||
'version': '10.0.1.0.0',
|
|
||||||
'category': 'Sales',
|
|
||||||
'license': 'AGPL-3',
|
|
||||||
'summary': 'Allows to force a sale order to invoiced status',
|
|
||||||
'description': """
|
|
||||||
Sale Force Invoice Status
|
|
||||||
=========================
|
|
||||||
|
|
||||||
Add a button on sale orders that allow to force the *Invoice Status* of the order to *Invoiced* (button restricted to members of the *Sale Manager* group).
|
|
||||||
|
|
||||||
This module has been written by Alexis de Lattre from Akretion
|
|
||||||
<alexis.delattre@akretion.com>.
|
|
||||||
""",
|
|
||||||
'author': 'Akretion',
|
|
||||||
'website': 'http://www.akretion.com',
|
|
||||||
'depends': ['sale'],
|
|
||||||
'data': [
|
|
||||||
'sale_view.xml',
|
|
||||||
],
|
|
||||||
'installable': True,
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright (C) 2018 Akretion (http://www.akretion.com)
|
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
|
||||||
|
|
||||||
from odoo import models, fields, api, _
|
|
||||||
from odoo.exceptions import UserError
|
|
||||||
|
|
||||||
|
|
||||||
class SaleOrder(models.Model):
|
|
||||||
_inherit = 'sale.order'
|
|
||||||
|
|
||||||
def force_invoice_status_to_invoiced(self):
|
|
||||||
for order in self:
|
|
||||||
if order.state not in ('sale', 'done'):
|
|
||||||
raise UserError(_(
|
|
||||||
"You are trying to force the sale order %s to invoiced "
|
|
||||||
"but it is not in 'Sales Order' or 'Locked' state.")
|
|
||||||
% order.name)
|
|
||||||
if order.invoice_status != 'to invoice':
|
|
||||||
raise UserError(_(
|
|
||||||
"You are trying to force the sale order %s to invoiced "
|
|
||||||
"but its invoice status is not 'To Invoice'.")
|
|
||||||
% order.name)
|
|
||||||
order.order_line.write({'forced_to_invoiced': True})
|
|
||||||
order.message_post(_(
|
|
||||||
"Order <b>forced to Invoiced</b> via the special button"))
|
|
||||||
|
|
||||||
|
|
||||||
class SaleOrderLine(models.Model):
|
|
||||||
_inherit = 'sale.order.line'
|
|
||||||
|
|
||||||
forced_to_invoiced = fields.Boolean()
|
|
||||||
|
|
||||||
@api.depends(
|
|
||||||
'state', 'product_uom_qty', 'qty_delivered', 'qty_to_invoice',
|
|
||||||
'qty_invoiced', 'forced_to_invoiced')
|
|
||||||
def _compute_invoice_status(self):
|
|
||||||
super(SaleOrderLine, self)._compute_invoice_status()
|
|
||||||
for line in self:
|
|
||||||
if line.state in ('sale', 'done') and line.forced_to_invoiced:
|
|
||||||
line.invoice_status = 'invoiced'
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
© 2018 Akretion (http://www.akretion.com/)
|
|
||||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
-->
|
|
||||||
|
|
||||||
<odoo>
|
|
||||||
|
|
||||||
<record id="view_order_form" model="ir.ui.view">
|
|
||||||
<field name="name">sale_force_invoice_status.sale.order.form</field>
|
|
||||||
<field name="model">sale.order</field>
|
|
||||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<button name="action_cancel" type="object" position="before">
|
|
||||||
<button name="force_invoice_status_to_invoiced"
|
|
||||||
type="object" string="Force to Invoiced"
|
|
||||||
confirm="Are you sure you want to force this order to Invoiced ?"
|
|
||||||
attrs="{'invisible': ['|', ('state', 'not in', ('sale', 'done')), ('invoice_status', '!=', 'to invoice')]}"
|
|
||||||
groups="sales_team.group_sale_manager"/>
|
|
||||||
</button>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
|
|
||||||
</odoo>
|
|
||||||
Reference in New Issue
Block a user