Skip to content

sale: Odoo Sale Order Zero Stock Approval Feature #711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions zero_stock_blockage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions zero_stock_blockage/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
'name': "Zero Stock Blockage",
'version': '1.0',
'depends': ['base', 'sale_management'],
'author': "Rishav Shah",
'category': 'sales',
'description': """
Zero Stock Blockage (Sales Order)
""",
'installable': True,
'application': True,
'license': 'LGPL-3',
'data': [
'views/sale_order_views.xml',
],
}
1 change: 1 addition & 0 deletions zero_stock_blockage/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_order
26 changes: 26 additions & 0 deletions zero_stock_blockage/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from odoo import api, fields, models
from odoo.exceptions import ValidationError


class SaleOrder(models.Model):
_inherit = 'sale.order'

zero_stock_approvalexchttps = fields.Boolean(string="Approval", default=False)

def action_confirm(self):
res = super().action_confirm()
for order in self:
if not order.zero_stock_approvalexchttps:
raise ValidationError("Please check for approval to confirm SO")
return res

readonly_status = fields.Boolean(
compute='_compute_readonly_status',
string="Zero Stock Approval Status"
)

@api.depends_context('uid')
def _compute_readonly_status(self):
readonly_status = self.env.user.has_group('sales_team.group_sale_manager')
for record in self:
record.readonly_status = readonly_status
12 changes: 12 additions & 0 deletions zero_stock_blockage/views/sale_order_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<odoo>
<record id="view_sale_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='payment_term_id']" position="after">
<field name="zero_stock_approvalexchttps" readonly="not readonly_status"/>
</xpath>
</field>
</record>
</odoo>