Add module sale_force_invoice_status

This commit is contained in:
Alexis de Lattre
2018-02-02 18:27:22 +01:00
parent 782f1fdb92
commit 054bee90c0
8 changed files with 102 additions and 4 deletions

View File

@@ -5,7 +5,7 @@
{
'name': 'Sale Confirm Wizard',
'version': '10.0.1.0.0',
'category': 'Sale Management',
'category': 'Sales',
'license': 'AGPL-3',
'summary': 'Open a wizard when you confirm a sale order to update important info',
'description': """

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import sale

View File

@@ -0,0 +1,28 @@
# -*- 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,
}

View File

@@ -0,0 +1,41 @@
# -*- 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'

View File

@@ -0,0 +1,26 @@
<?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>

View File

@@ -5,7 +5,7 @@
{
'name': 'Sale Order Add Bom',
'version': '10.0.1.0.0',
'category': 'Sales Management',
'category': 'Sales',
'license': 'AGPL-3',
'summary': 'Wizard to select a bom from a sale order',
'description': """

View File

@@ -6,7 +6,7 @@
{
'name': 'Sale Quotation Title',
'version': '10.0.1.0.0',
'category': 'Sale Management',
'category': 'Sales',
'license': 'AGPL-3',
'summary': 'Adds a title field on quotations',
'description': """

View File

@@ -6,7 +6,7 @@
{
'name': 'Sale Usability',
'version': '10.0.0.1.0',
'category': 'Sale Management',
'category': 'Sales',
'license': 'AGPL-3',
'summary': 'Show invoices on sale orders',
'description': """