commit
ad215f5f7f
|
|
@ -1 +1,2 @@
|
||||||
from . import models
|
from . import models
|
||||||
|
from . import wizard
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
"views/purchase_requisition.xml",
|
"views/purchase_requisition.xml",
|
||||||
"data/mail_activity.xml",
|
"data/mail_activity.xml",
|
||||||
"views/menu.xml",
|
"views/menu.xml",
|
||||||
|
"wizard/annual_cancel_wizard_view.xml"
|
||||||
],
|
],
|
||||||
"application": True,
|
"application": True,
|
||||||
"installable": True
|
"installable": True
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,11 @@ msgstr "الطلبات السنوية"
|
||||||
msgid "Approve"
|
msgid "Approve"
|
||||||
msgstr "موافقة"
|
msgstr "موافقة"
|
||||||
|
|
||||||
|
#. module: odex25_annual_purchase
|
||||||
|
#: model_terms:ir.ui.view,arch_db:odex25_annual_purchase.view_odx_annual_request_form
|
||||||
|
msgid "Back To Draft"
|
||||||
|
msgstr "إعادة الى مسودة"
|
||||||
|
|
||||||
#. module: odex25_annual_purchase
|
#. module: odex25_annual_purchase
|
||||||
#: code:addons/odex25_annual_purchase/models/annual_request.py:0
|
#: code:addons/odex25_annual_purchase/models/annual_request.py:0
|
||||||
#, python-format
|
#, python-format
|
||||||
|
|
@ -195,6 +200,16 @@ msgstr "أعضاء لجنة المشتريات"
|
||||||
msgid "Committee / Technical"
|
msgid "Committee / Technical"
|
||||||
msgstr "اللجنة / الفنية"
|
msgstr "اللجنة / الفنية"
|
||||||
|
|
||||||
|
#. module: odex25_annual_purchase
|
||||||
|
#: model:res.groups,name:odex25_annual_purchase.group_annual_committee
|
||||||
|
msgid "Committee"
|
||||||
|
msgstr "اللجنة / المالية"
|
||||||
|
|
||||||
|
#. module: odex25_annual_purchase
|
||||||
|
#: model:res.groups,name:odex25_annual_purchase.group_annual_to_draft
|
||||||
|
msgid "To Draft"
|
||||||
|
msgstr "إعادة الى مسودة"
|
||||||
|
|
||||||
#. module: odex25_annual_purchase
|
#. module: odex25_annual_purchase
|
||||||
#: model:ir.model.fields,field_description:odex25_annual_purchase.field_odx_annual_request__committe_head
|
#: model:ir.model.fields,field_description:odex25_annual_purchase.field_odx_annual_request__committe_head
|
||||||
msgid "Committee Head"
|
msgid "Committee Head"
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class AnnualPurchaseRequest(models.Model):
|
||||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||||
_order = "create_date desc"
|
_order = "create_date desc"
|
||||||
|
|
||||||
name = fields.Char(string="Reference", default=lambda self: self.env['ir.sequence'].next_by_code('odx.annual.request'), readonly=True, copy=False)
|
name = fields.Char(string="Reference", default="New", readonly=True, copy=False)
|
||||||
employee_id = fields.Many2one('hr.employee', string="Employee", tracking=True, default=lambda self: self.env['hr.employee'].search([('user_id', '=', self.env.user.id)], limit=1))
|
employee_id = fields.Many2one('hr.employee', string="Employee", tracking=True, default=lambda self: self.env['hr.employee'].search([('user_id', '=', self.env.user.id)], limit=1))
|
||||||
user_id = fields.Many2one('res.users', string="Requested By", default=lambda self: self.env.user, tracking=True)
|
user_id = fields.Many2one('res.users', string="Requested By", default=lambda self: self.env.user, tracking=True)
|
||||||
department_id = fields.Many2one('hr.department', string="Department", tracking=True, related='employee_id.department_id', store=True)
|
department_id = fields.Many2one('hr.department', string="Department", tracking=True, related='employee_id.department_id', store=True)
|
||||||
|
|
@ -101,6 +101,13 @@ class AnnualPurchaseRequest(models.Model):
|
||||||
},
|
},
|
||||||
'target': 'current',
|
'target': 'current',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def create(self, vals):
|
||||||
|
if vals.get('name', 'New') in (False, '/', 'New'):
|
||||||
|
vals['name'] = self.env['ir.sequence'].next_by_code('odx.annual.request') or 'New'
|
||||||
|
return super(AnnualPurchaseRequest, self).create(vals)
|
||||||
|
|
||||||
def _compute_attach_no(self):
|
def _compute_attach_no(self):
|
||||||
Attachment = self.env['ir.attachment']
|
Attachment = self.env['ir.attachment']
|
||||||
for rec in self:
|
for rec in self:
|
||||||
|
|
@ -147,6 +154,7 @@ class AnnualPurchaseRequest(models.Model):
|
||||||
default = dict(default or {})
|
default = dict(default or {})
|
||||||
|
|
||||||
default.update({
|
default.update({
|
||||||
|
'name': 'New',
|
||||||
'committee_recommended_vendor_id': False,
|
'committee_recommended_vendor_id': False,
|
||||||
'committee_enabled': False,
|
'committee_enabled': False,
|
||||||
'committee_type_id': False,
|
'committee_type_id': False,
|
||||||
|
|
@ -326,6 +334,10 @@ class AnnualPurchaseRequest(models.Model):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
rec.write({'state': 'to_manager'})
|
rec.write({'state': 'to_manager'})
|
||||||
|
|
||||||
|
def action_to_draft(self):
|
||||||
|
for rec in self:
|
||||||
|
rec.write({'state': 'draft'})
|
||||||
|
|
||||||
def action_manager_approve(self):
|
def action_manager_approve(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
manager = rec.sudo().employee_id.parent_id
|
manager = rec.sudo().employee_id.parent_id
|
||||||
|
|
@ -384,14 +396,17 @@ class AnnualPurchaseRequest(models.Model):
|
||||||
self.write({'state':'rejected'})
|
self.write({'state':'rejected'})
|
||||||
|
|
||||||
def action_cancel(self):
|
def action_cancel(self):
|
||||||
for request in self:
|
self.ensure_one()
|
||||||
related_orders = self.env['purchase.order'].search([('annual_request_id', '=', request.id)])
|
return {
|
||||||
|
'name': _('Cancel Request'),
|
||||||
for order in related_orders:
|
'type': 'ir.actions.act_window',
|
||||||
if order.state:
|
'res_model': 'odx.annual.request.cancel.wizard',
|
||||||
order.button_cancel()
|
'view_mode': 'form',
|
||||||
|
'target': 'new',
|
||||||
request.write({'state': 'cancel'})
|
'context': {
|
||||||
|
'default_request_id': self.id,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
def action_create_agreement(self):
|
def action_create_agreement(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,4 @@ access_request_gm,access_request_gm,model_odx_annual_request,hr_base.group_gener
|
||||||
access_request_line_staff,access_request_line_staff,model_odx_annual_request_line,purchase.group_purchase_user,1,1,1,0
|
access_request_line_staff,access_request_line_staff,model_odx_annual_request_line,purchase.group_purchase_user,1,1,1,0
|
||||||
access_addendum_staff,access_addendum_staff,model_odx_annual_addendum,purchase.group_purchase_user,1,1,1,0
|
access_addendum_staff,access_addendum_staff,model_odx_annual_addendum,purchase.group_purchase_user,1,1,1,0
|
||||||
access_addendum_line_staff,access_addendum_line_staff,model_odx_annual_addendum_line,purchase.group_purchase_user,1,1,1,0
|
access_addendum_line_staff,access_addendum_line_staff,model_odx_annual_addendum_line,purchase.group_purchase_user,1,1,1,0
|
||||||
|
access_odx_annual_request_cancel_wizard_user,odx_annual_request_cancel_wizard_user,model_odx_annual_request_cancel_wizard,base.group_user,1,1,1,1
|
||||||
|
|
|
||||||
|
|
|
@ -15,4 +15,8 @@
|
||||||
<field name="name">Committee</field>
|
<field name="name">Committee</field>
|
||||||
<field name="category_id" ref="module_category_purchase_management"/>
|
<field name="category_id" ref="module_category_purchase_management"/>
|
||||||
</record>
|
</record>
|
||||||
|
<record id="group_annual_to_draft" model="res.groups">
|
||||||
|
<field name="name">To Draft</field>
|
||||||
|
<field name="category_id" ref="module_category_purchase_management"/>
|
||||||
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@
|
||||||
<button name="action_ssd_reject" string="Reject" type="object" states="ssd" groups="hr_base.group_services_manager"/>
|
<button name="action_ssd_reject" string="Reject" type="object" states="ssd" groups="hr_base.group_services_manager"/>
|
||||||
<button name="action_ceo_approve" string="Approve" class="oe_highlight" type="object" states="ceo" groups="hr_base.group_general_manager"/>
|
<button name="action_ceo_approve" string="Approve" class="oe_highlight" type="object" states="ceo" groups="hr_base.group_general_manager"/>
|
||||||
<button name="action_ceo_reject" string="Reject" type="object" states="ceo" groups="hr_base.group_general_manager"/>
|
<button name="action_ceo_reject" string="Reject" type="object" states="ceo" groups="hr_base.group_general_manager"/>
|
||||||
<button name="action_create_agreement" string="Create Agreement" type="object" states="purchase" class="oe_highlight"/>
|
<button name="action_create_agreement" string="Create Agreement" type="object" states="purchase" class="oe_highlight" groups="purchase.group_purchase_manager"/>
|
||||||
|
<button name="action_to_draft" string="Back To Draft" type="object" states="rejected" class="oe_highlight" groups="odex25_annual_purchase.group_annual_to_draft" />
|
||||||
<field name="state" widget="statusbar" statusbar_visible="draft,to_manager,procurement,committee,ssd,ceo,approved,rejected,cancel"/>
|
<field name="state" widget="statusbar" statusbar_visible="draft,to_manager,procurement,committee,ssd,ceo,approved,rejected,cancel"/>
|
||||||
</header>
|
</header>
|
||||||
<sheet>
|
<sheet>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
from . import annual_cancel_wizard
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
from odoo import api, fields, models, _
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
class AnnualRequestCancelWizard(models.TransientModel):
|
||||||
|
_name = 'odx.annual.request.cancel.wizard'
|
||||||
|
_description = 'Cancel Annual Request Wizard'
|
||||||
|
|
||||||
|
request_id = fields.Many2one('odx.annual.request', string='Request', required=True)
|
||||||
|
reason = fields.Text(string='Cancellation Reason', required=True)
|
||||||
|
|
||||||
|
def action_confirm(self):
|
||||||
|
self.ensure_one()
|
||||||
|
request = self.request_id
|
||||||
|
|
||||||
|
related_orders = self.env['purchase.order'].search([('annual_request_id', '=', request.id)])
|
||||||
|
for order in related_orders:
|
||||||
|
if order.state:
|
||||||
|
order.button_cancel()
|
||||||
|
|
||||||
|
request.message_post(body=_("Cancelled: %s") % (self.reason or ''))
|
||||||
|
|
||||||
|
vals = {'state': 'cancel'}
|
||||||
|
if 'cancel_reason' in request._fields:
|
||||||
|
vals['cancel_reason'] = self.reason
|
||||||
|
request.write(vals)
|
||||||
|
|
||||||
|
return {'type': 'ir.actions.act_window_close'}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<odoo>
|
||||||
|
<!-- Wizard Form View -->
|
||||||
|
<record id="view_odx_annual_request_cancel_wizard_form" model="ir.ui.view">
|
||||||
|
<field name="name">odx.annual.request.cancel.wizard.form</field>
|
||||||
|
<field name="model">odx.annual.request.cancel.wizard</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Cancel Request">
|
||||||
|
<group>
|
||||||
|
<field name="request_id" invisible="1"/>
|
||||||
|
<field name="reason" placeholder="اكتب سبب الإلغاء..." required="1"/>
|
||||||
|
</group>
|
||||||
|
<footer>
|
||||||
|
<button name="action_confirm" type="object" string="Confirm" class="btn-primary"/>
|
||||||
|
<button string="Discard" special="cancel" class="btn-secondary"/>
|
||||||
|
</footer>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_odx_annual_request_cancel_wizard" model="ir.actions.act_window">
|
||||||
|
<field name="name">Cancel Request</field>
|
||||||
|
<field name="res_model">odx.annual.request.cancel.wizard</field>
|
||||||
|
<field name="view_mode">form</field>
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Loading…
Reference in New Issue