[imp] sale_order_batch: Add invoice status and menues
This commit is contained in:
parent
d31e45814a
commit
91a3e8b8d6
7 changed files with 77 additions and 8 deletions
|
|
@ -41,6 +41,7 @@ Changelog
|
||||||
:1.1.1: Remove validity date
|
:1.1.1: Remove validity date
|
||||||
:2.0.0: Move product logic to sale order lines
|
:2.0.0: Move product logic to sale order lines
|
||||||
:2.1.0: Add "In Progress" and "Cancelled" state
|
:2.1.0: Add "In Progress" and "Cancelled" state
|
||||||
|
:2.1.0: Add invoice status and menues
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"author": "BAKEUP",
|
"author": "BAKEUP",
|
||||||
"website": "https://www.bakeup.org",
|
"website": "https://www.bakeup.org",
|
||||||
"category": "Sale",
|
"category": "Sale",
|
||||||
"version": "16.0.2.1.0",
|
"version": "16.0.2.2.0",
|
||||||
"depends": ["sale", "product"],
|
"depends": ["sale", "product"],
|
||||||
"data": [
|
"data": [
|
||||||
"data/ir_sequence_data.xml",
|
"data/ir_sequence_data.xml",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
|
|
||||||
|
from odoo.addons.sale.models.sale_order import INVOICE_STATUS
|
||||||
|
|
||||||
|
|
||||||
STATES = [("open", "Open"), ("in_progress", "In Progress"), ("closed", "Closed"), ("cancel", "Cancelled")]
|
STATES = [("open", "Open"), ("in_progress", "In Progress"), ("closed", "Closed"), ("cancel", "Cancelled")]
|
||||||
READONLY_FIELD_STATES = {state: [("readonly", True)] for state in {"closed"}}
|
READONLY_FIELD_STATES = {state: [("readonly", True)] for state in {"closed"}}
|
||||||
|
|
@ -42,6 +44,7 @@ class SaleOrderBatch(models.Model):
|
||||||
sale_order_line_ids = fields.One2many("sale.order.line", "batch_id", states=READONLY_FIELD_STATES)
|
sale_order_line_ids = fields.One2many("sale.order.line", "batch_id", states=READONLY_FIELD_STATES)
|
||||||
invoice_ids = fields.Many2many("account.move", compute="_compute_invoice_ids")
|
invoice_ids = fields.Many2many("account.move", compute="_compute_invoice_ids")
|
||||||
invoice_count = fields.Integer(compute="_compute_invoice_ids")
|
invoice_count = fields.Integer(compute="_compute_invoice_ids")
|
||||||
|
invoice_status = fields.Selection(selection=INVOICE_STATUS, compute="_compute_invoice_status", store=True)
|
||||||
amount_total = fields.Float(compute="_compute_amount_total", string="Total")
|
amount_total = fields.Float(compute="_compute_amount_total", string="Total")
|
||||||
product_ids = fields.One2many("sale.order.batch.product", "batch_id")
|
product_ids = fields.One2many("sale.order.batch.product", "batch_id")
|
||||||
product_count = fields.Integer(compute="_compute_product_count")
|
product_count = fields.Integer(compute="_compute_product_count")
|
||||||
|
|
@ -59,6 +62,25 @@ class SaleOrderBatch(models.Model):
|
||||||
batch.invoice_ids = invoices
|
batch.invoice_ids = invoices
|
||||||
batch.invoice_count = len(invoices)
|
batch.invoice_count = len(invoices)
|
||||||
|
|
||||||
|
@api.depends("sale_order_ids.invoice_status")
|
||||||
|
def _compute_invoice_status(self):
|
||||||
|
for batch in self:
|
||||||
|
if batch.sale_order_ids and any(
|
||||||
|
invoice_status == "to invoice" for invoice_status in batch.sale_order_ids.mapped("invoice_status")
|
||||||
|
):
|
||||||
|
batch.invoice_status = "to invoice"
|
||||||
|
elif batch.sale_order_ids and all(
|
||||||
|
invoice_status == "invoiced" for invoice_status in batch.sale_order_ids.mapped("invoice_status")
|
||||||
|
):
|
||||||
|
batch.invoice_status = "invoiced"
|
||||||
|
elif batch.sale_order_ids and all(
|
||||||
|
invoice_status in ("invoiced", "upselling")
|
||||||
|
for invoice_status in batch.sale_order_ids.mapped("invoice_status")
|
||||||
|
):
|
||||||
|
batch.invoice_status = "upselling"
|
||||||
|
else:
|
||||||
|
batch.invoice_status = "no"
|
||||||
|
|
||||||
@api.depends("sale_order_ids.amount_total")
|
@api.depends("sale_order_ids.amount_total")
|
||||||
def _compute_amount_total(self):
|
def _compute_amount_total(self):
|
||||||
for batch in self:
|
for batch in self:
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,4 @@
|
||||||
:1.1.1: Remove validity date
|
:1.1.1: Remove validity date
|
||||||
:2.0.0: Move product logic to sale order lines
|
:2.0.0: Move product logic to sale order lines
|
||||||
:2.1.0: Add "In Progress" and "Cancelled" state
|
:2.1.0: Add "In Progress" and "Cancelled" state
|
||||||
|
:2.1.0: Add invoice status and menues
|
||||||
|
|
@ -406,6 +406,8 @@ anymore as log as they are part of a batch. Only Sale Orders in state Qutotation
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">2.1.0:</th><td class="field-body">Add “In Progress” and “Cancelled” state</td>
|
<tr class="field"><th class="field-name">2.1.0:</th><td class="field-body">Add “In Progress” and “Cancelled” state</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="field"><th class="field-name">2.1.0:</th><td class="field-body">Add invoice status and menues</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,25 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
id="menu_quotation_batch"
|
||||||
|
action="action_quotation_batch"
|
||||||
|
parent="sale.sale_order_menu"
|
||||||
|
groups="sales_team.group_sale_salesman"
|
||||||
|
sequence="15"
|
||||||
|
/>
|
||||||
<menuitem
|
<menuitem
|
||||||
id="menu_sale_order_batch"
|
id="menu_sale_order_batch"
|
||||||
name="Order Batches"
|
action="action_order_batch"
|
||||||
action="action_batch"
|
|
||||||
parent="sale.sale_order_menu"
|
parent="sale.sale_order_menu"
|
||||||
groups="sales_team.group_sale_salesman"
|
groups="sales_team.group_sale_salesman"
|
||||||
sequence="25"
|
sequence="25"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
id="menu_sale_order_batch_invoice"
|
||||||
|
action="action_batch_to_invoice"
|
||||||
|
parent="sale.menu_sale_invoicing"
|
||||||
|
sequence="15"
|
||||||
|
/>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,14 @@
|
||||||
<field name="company_id" groups="base.group_multi_company" optional="show" readonly="1"/>
|
<field name="company_id" groups="base.group_multi_company" optional="show" readonly="1"/>
|
||||||
<field name="company_id" groups="!base.group_multi_company" invisible="1"/>
|
<field name="company_id" groups="!base.group_multi_company" invisible="1"/>
|
||||||
<field name="sale_order_ids" widget="many2many_tags"/>
|
<field name="sale_order_ids" widget="many2many_tags"/>
|
||||||
|
<field
|
||||||
|
name="invoice_status"
|
||||||
|
decoration-success="invoice_status == 'invoiced'"
|
||||||
|
decoration-info="invoice_status == 'to invoice'"
|
||||||
|
decoration-warning="invoice_status == 'upselling'"
|
||||||
|
widget="badge"
|
||||||
|
optional="show"
|
||||||
|
/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
|
@ -185,18 +193,40 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search>
|
<search>
|
||||||
<filter string="Active" name="filter_batch_open" domain="[('state', 'in', ['open', 'in_progress'])]"/>
|
<filter string="Active" name="filter_batch_open" domain="[('state', 'in', ['open', 'in_progress'])]"/>
|
||||||
<filter string="To Invoice" name="filter_batch_to_invoice" domain="[('state', '=', 'closed')]"/>
|
<filter string="Finished" name="filter_batch_finished" domain="[('state', '=', 'closed')]"/>
|
||||||
<filter string="Cancelled" name="filter_batch_cancel" domain="[('state', '=', 'cancel')]"/>
|
<filter string="Cancelled" name="filter_batch_cancel" domain="[('state', '=', 'cancel')]"/>
|
||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="action_quotation_batch" model="ir.actions.act_window">
|
||||||
<record id="action_batch" model="ir.actions.act_window">
|
<field name="name">Quotation Batches</field>
|
||||||
<field name="name">Sale Order Batches</field>
|
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">sale.order.batch</field>
|
<field name="res_model">sale.order.batch</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form,activity</field>
|
||||||
<field name="context">{'search_default_filter_batch_open': 1}</field>
|
<field name="context">{'search_default_filter_batch_open': 1}</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="action_order_batch" model="ir.actions.act_window">
|
||||||
|
<field name="name">Order Batches</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">sale.order.batch</field>
|
||||||
|
<field name="view_mode">tree,form,activity</field>
|
||||||
|
<field name="context">{'search_default_filter_batch_finished': 1}</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_batch_to_invoice" model="ir.actions.act_window">
|
||||||
|
<field name="name">Batches to Invoice</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">sale.order.batch</field>
|
||||||
|
<field name="view_mode">tree,form,activity</field>
|
||||||
|
<field name="context">{'create': False}</field>
|
||||||
|
<field name="domain">[('invoice_status','=','to invoice')]</field>
|
||||||
|
<field name="search_view_id" ref="sale_order_batch_view_search"/>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
No batches to invoice found
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue