Merge pull request #219 from expsa/dev_odex25_purchase_changes
add custom stock for standard module
This commit is contained in:
commit
4bec1059e6
|
|
@ -0,0 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from . import models
|
||||
from . import wizards
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
{
|
||||
'name': 'Purchase Custom Stock',
|
||||
'version': '1.1',
|
||||
'summary': 'Adding new Functionality on the Purchase Agreements',
|
||||
'sequence': -1,
|
||||
'description': """
|
||||
Adding new Functionalities in Purchase Agreements
|
||||
""",
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'data/purchase_request.xml',
|
||||
'views/purchase_request.xml',
|
||||
'wizards/picking_purchase_request.xml'
|
||||
|
||||
],
|
||||
'depends': ['stock', 'purchase_requisition', 'purchase_requisition_custom'],
|
||||
'installable': True,
|
||||
'application': True,
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- Operation type for purchase_requisition-->
|
||||
<record id="stock_picking_type_stock" model="stock.picking.type">
|
||||
<field name="name">Out From Stock</field>
|
||||
<field name="code">outgoing</field>
|
||||
<field name="sequence_code">out</field>
|
||||
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,262 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * purchase_custom_stock
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-07-03 02:56+0000\n"
|
||||
"PO-Revision-Date: 2024-07-03 02:56+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request_picking_wizard__is_available
|
||||
msgid "Available"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request_line__available_qty
|
||||
msgid "Available Qty"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model_terms:ir.ui.view,arch_db:purchase_custom_stock.purchase_request_form_inherit
|
||||
msgid "Available Quantity"
|
||||
msgstr "فحص الكمية المتوفرة"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: code:addons/purchase_custom_stock/models/purchase_request.py:0
|
||||
#: code:addons/purchase_custom_stock/models/purchase_request.py:0
|
||||
#, python-format
|
||||
msgid "Can't Confirm Request With No Item!"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields.selection,name:purchase_custom_stock.selection__purchase_request__state__cancel
|
||||
#: model_terms:ir.ui.view,arch_db:purchase_custom_stock.purchase_request_picking_wizard_view_form
|
||||
msgid "Cancel"
|
||||
msgstr "إلغاء"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model_terms:ir.ui.view,arch_db:purchase_custom_stock.purchase_request_picking_wizard_view_form
|
||||
msgid "Cancel Request Reason"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: code:addons/purchase_custom_stock/models/purchase_request.py:0
|
||||
#, python-format
|
||||
msgid "Choose A Department For this Employee!"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model_terms:ir.ui.view,arch_db:purchase_custom_stock.purchase_request_form_inherit
|
||||
msgid "Confirm"
|
||||
msgstr "اعتماد"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model_terms:ir.ui.view,arch_db:purchase_custom_stock.purchase_request_picking_wizard_view_form
|
||||
msgid "Convert Purchase"
|
||||
msgstr "تحويل الى المشتريات"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request_picking_wizard__create_uid
|
||||
msgid "Created by"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request_picking_wizard__create_date
|
||||
msgid "Created on"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model_terms:ir.ui.view,arch_db:purchase_custom_stock.purchase_request_form_inherit
|
||||
msgid "Delivery"
|
||||
msgstr "استلام"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model_terms:ir.ui.view,arch_db:purchase_custom_stock.purchase_request_form_inherit
|
||||
msgid "Delivery Done"
|
||||
msgstr "تم الستلام"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model_terms:ir.ui.view,arch_db:purchase_custom_stock.purchase_request_picking_wizard_view_form
|
||||
msgid "Delivery and Close"
|
||||
msgstr "تسليم المتوفر واغلاق الطلب "
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model_terms:ir.ui.view,arch_db:purchase_custom_stock.purchase_request_picking_wizard_view_form
|
||||
msgid "Delivery and Purchase"
|
||||
msgstr "تسليم المتوفر وشراء الباقى"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request_line__qty
|
||||
msgid "Demand Qty"
|
||||
msgstr "الكمية المطلوبة"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields.selection,name:purchase_custom_stock.selection__purchase_request__state__direct_manager
|
||||
msgid "Direct Manager"
|
||||
msgstr "المدير المباشر"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request_picking_wizard__display_name
|
||||
msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields.selection,name:purchase_custom_stock.selection__purchase_request__state__done
|
||||
msgid "Done"
|
||||
msgstr "تم"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields.selection,name:purchase_custom_stock.selection__purchase_request__state__draft
|
||||
msgid "Draft"
|
||||
msgstr "مبدئي"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request__edit_locations
|
||||
msgid "Edit Locations"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields.selection,name:purchase_custom_stock.selection__purchase_request__state__employee
|
||||
msgid "Employee Delivery"
|
||||
msgstr "استلام موظف"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request_picking_wizard__id
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields.selection,name:purchase_custom_stock.selection__purchase_request__state__waiting
|
||||
msgid "In Purchase"
|
||||
msgstr "ادارة المشتريات"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: code:addons/purchase_custom_stock/models/purchase_request.py:0
|
||||
#, python-format
|
||||
msgid "Item Quantity MUST be at Least ONE!"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request_picking_wizard____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request_picking_wizard__write_uid
|
||||
msgid "Last Updated by"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request_picking_wizard__write_date
|
||||
msgid "Last Updated on"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request__location_id
|
||||
msgid "Location"
|
||||
msgstr "الموقع/المكان"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:stock.picking.type,name:purchase_custom_stock.stock_picking_type_stock
|
||||
msgid "Out From Stock"
|
||||
msgstr "صرف من المخزون"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request__picking_id
|
||||
msgid "Picking"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: code:addons/purchase_custom_stock/models/purchase_request.py:0
|
||||
#, python-format
|
||||
msgid "Picking Options"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.actions.act_window,name:purchase_custom_stock.purchase_request_picking_wizard_action
|
||||
msgid "Picking Options Request"
|
||||
msgstr "اختيارات الاستلام"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: code:addons/purchase_custom_stock/models/purchase_request.py:0
|
||||
#, python-format
|
||||
msgid "Picking Request"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: code:addons/purchase_custom_stock/models/purchase_request.py:0
|
||||
#, python-format
|
||||
msgid "Please Insert Location first"
|
||||
msgstr "يرجى اختيار المستودع و الموقع"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: code:addons/purchase_custom_stock/models/purchase_request.py:0
|
||||
#: code:addons/purchase_custom_stock/models/purchase_request.py:0
|
||||
#, python-format
|
||||
msgid "Please Select department for employee"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request_line__qty_purchased
|
||||
msgid "Purchase Qty"
|
||||
msgstr "الكمية المطلوبة للشراء"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model,name:purchase_custom_stock.model_purchase_request
|
||||
msgid "Purchase Request"
|
||||
msgstr "طلبات الشراء"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields.selection,name:purchase_custom_stock.selection__purchase_request__state__refuse
|
||||
msgid "Refuse"
|
||||
msgstr "رفض"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request_picking_wizard__request_id
|
||||
msgid "Request"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request_picking_wizard__request_line_ids
|
||||
msgid "Request Line"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request__show_emp_button
|
||||
msgid "Show Emp Button"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request__state
|
||||
msgid "State"
|
||||
msgstr "الحالة"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request__view_location_id
|
||||
#: model:ir.model.fields,field_description:purchase_custom_stock.field_purchase_request__warehouse_id
|
||||
msgid "Warehouse"
|
||||
msgstr "المستودع"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model.fields.selection,name:purchase_custom_stock.selection__purchase_request__state__warehouse
|
||||
msgid "Warehouses Department"
|
||||
msgstr "ادارة المسودعات"
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model,name:purchase_custom_stock.model_purchase_request_picking_wizard
|
||||
msgid "purchase Checking Options wizard"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_custom_stock
|
||||
#: model:ir.model,name:purchase_custom_stock.model_purchase_request_line
|
||||
msgid "purchase request line"
|
||||
msgstr "بند طلب الشراء"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
from . import purchase_request
|
||||
|
|
@ -0,0 +1,215 @@
|
|||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from datetime import datetime, timedelta, date
|
||||
from odoo.tools.misc import get_lang
|
||||
from odoo.addons.purchase.models.purchase import PurchaseOrder as Purchase
|
||||
|
||||
|
||||
class PurchaseRequest(models.Model):
|
||||
_inherit = 'purchase.request'
|
||||
|
||||
|
||||
warehouse_id = fields.Many2one("stock.warehouse", string= "Warehouse" )
|
||||
view_location_id = fields.Many2one(related="warehouse_id.view_location_id", string= "Warehouse" )
|
||||
location_id = fields.Many2one("stock.location", string= "Location",domain="[('id', 'child_of', view_location_id),('usage', '=', 'internal')]" )
|
||||
picking_id=fields.Many2one("stock.picking")
|
||||
edit_locations=fields.Boolean(string="Edit Locations",compute='compute_edit_locations')
|
||||
state = fields.Selection(
|
||||
[('draft', 'Draft'), ('direct_manager', 'Direct Manager'),('warehouse', 'Warehouses Department'),
|
||||
('waiting', 'In Purchase'),('employee', 'Employee Delivery'),('done', 'Done'), ('cancel', 'Cancel'), ('refuse', 'Refuse')], default="draft",
|
||||
tracking=True, )
|
||||
show_emp_button=fields.Boolean(compute='show_employee_button')
|
||||
|
||||
def show_employee_button(self):
|
||||
"""show only for the create employee"""
|
||||
for rec in self:
|
||||
rec.show_emp_button=False
|
||||
if rec.create_uid.id == self.env.user.id and rec.state == 'employee':
|
||||
rec.show_emp_button=True
|
||||
|
||||
|
||||
def compute_edit_locations(self):
|
||||
"""Compute For Group Edit Warehouse/Locations"""
|
||||
for rec in self:
|
||||
if self.env.user.has_group("stock.group_stock_user") or self.env.user.has_group(
|
||||
"stock.group_stock_manager") :
|
||||
rec.edit_locations = True
|
||||
else:
|
||||
rec.edit_locations = False
|
||||
|
||||
def action_confirm(self):
|
||||
if len(self.line_ids) == 0:
|
||||
raise ValidationError(_("Can't Confirm Request With No Item!"))
|
||||
if not self.department_id:
|
||||
raise ValidationError(_("Please Select department for employee"))
|
||||
service_products=self.line_ids.filtered(lambda line: line.product_id.type == "service")
|
||||
if len(service_products) == len(self.line_ids):
|
||||
self.write({'state': 'waiting'})
|
||||
else:
|
||||
self.write({'state': 'warehouse'})
|
||||
|
||||
|
||||
def create_requisition(self):
|
||||
"""inherit for take in considiration available qty """
|
||||
self.is_requisition = True
|
||||
if not self.employee_id.department_id:
|
||||
raise ValidationError(_("Choose A Department For this Employee!"))
|
||||
line_ids = []
|
||||
for line in self.line_ids:
|
||||
line_ids.append((0, 6, {
|
||||
'product_id': line.product_id.id,
|
||||
'department_id': line.request_id.department_id.id or False,
|
||||
'product_qty': line.qty-line.available_qty,
|
||||
'name': line.product_id.name,
|
||||
'account_analytic_id': line.account_id.id,
|
||||
}))
|
||||
requisition_id = self.env['purchase.requisition'].sudo().create({
|
||||
'category_ids': self.product_category_ids.ids,
|
||||
'type_id_test': self.type_id.id,
|
||||
'department_id': self.employee_id.department_id.id,
|
||||
'type': self.type,
|
||||
'purpose': self.purchase_purpose,
|
||||
'request_id': self.id,
|
||||
'user_id': self.employee_id.user_id.id,
|
||||
'line_ids': line_ids
|
||||
})
|
||||
self.write({'purchase_create': True,'state':'employee'})
|
||||
|
||||
return {
|
||||
'name': "Request for Quotation",
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'purchase.requisition',
|
||||
'view_mode': 'form',
|
||||
'res_id': requisition_id.id,
|
||||
}
|
||||
|
||||
def create_purchase_order2(self):
|
||||
# if not self.partner_id :
|
||||
# raise ValidationError("Please Insert ")
|
||||
line_ids = []
|
||||
for line in self.line_ids.filtered(lambda line: line.qty_purchased > 0):
|
||||
line_ids.append((0, 6, {
|
||||
'product_id': line.product_id.id,
|
||||
'product_qty': line.qty-line.available_qty,
|
||||
'name':line.description or line.product_id.name,
|
||||
'department_name': self.employee_id.department_id.id,
|
||||
'account_analytic_id': line.account_id.id,
|
||||
'date_planned': datetime.today(),
|
||||
'price_unit': 0,
|
||||
}))
|
||||
|
||||
purchase_order = self.env['purchase.order'].sudo().create({
|
||||
'category_ids': self.product_category_ids.ids,
|
||||
'origin': self.name,
|
||||
'request_id': self.id,
|
||||
'partner_id': self.partner_id.id,
|
||||
'purpose': self.purchase_purpose,
|
||||
'purchase_cost': 'product_line',
|
||||
'order_line': line_ids,
|
||||
|
||||
})
|
||||
self.write({'purchase_create': True,'state':'employee'})
|
||||
|
||||
return {
|
||||
'name': "Purchase orders from employee",
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'purchase.order',
|
||||
'view_mode': 'form',
|
||||
'res_id': purchase_order.id}
|
||||
|
||||
def action_confirm_picking(self):
|
||||
if len(self.line_ids) == 0:
|
||||
raise ValidationError(_("Can't Confirm Request With No Item!"))
|
||||
if not self.department_id:
|
||||
raise ValidationError(_("Please Select department for employee"))
|
||||
available=False
|
||||
if any(self.line_ids.filtered(lambda line: line.available_qty >0 )):
|
||||
available=True
|
||||
|
||||
|
||||
if any(self.line_ids.filtered(lambda line: line.qty > line.available_qty)):
|
||||
context={}
|
||||
view = self.env.ref('purchase_custom_stock.purchase_request_picking_wizard_view_form')
|
||||
wiz = self.env['purchase.request_picking.wizard']
|
||||
context['default_request_id'] = self.id
|
||||
context['default_is_available'] = available
|
||||
|
||||
|
||||
context['default_request_line_ids'] = [(6,0,self.line_ids.filtered(lambda line: line.product_id.type != 'service').ids)]
|
||||
|
||||
return {
|
||||
'name': _('Picking Options'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'purchase.request_picking.wizard',
|
||||
'views': [(view.id, 'form')],
|
||||
'view_id': view.id,
|
||||
'target': 'new',
|
||||
'context': context,
|
||||
}
|
||||
else:
|
||||
picking_vals = {
|
||||
"picking_type_id": self.env.ref('purchase_custom_stock.stock_picking_type_stock').id,
|
||||
"origin": self.name,
|
||||
"location_id": self.location_id.id,
|
||||
"location_dest_id":self.picking_type_id.default_location_dest_id.id
|
||||
}
|
||||
|
||||
move_vals=[]
|
||||
for line in self.line_ids.filtered(lambda line: line.qty <= line.available_qty and line.product_id.type != 'service'):
|
||||
move_vals.append((0,0,{
|
||||
"product_id":line.product_id.id,
|
||||
"name":line.product_id.name,
|
||||
"product_uom":line.product_id.uom_id.id,
|
||||
'product_uom_qty': line.available_qty,
|
||||
|
||||
}))
|
||||
picking_vals.update({'move_lines':move_vals})
|
||||
picking_id = self.env['stock.picking'].create(picking_vals)
|
||||
self.picking_id = picking_id.id
|
||||
self.write({'state': 'employee'})
|
||||
|
||||
# self.picking_id.write({"move_lines":move_vals})
|
||||
|
||||
|
||||
def open_picking(self):
|
||||
|
||||
return {
|
||||
'name': _("Picking Request"),
|
||||
'view_mode': 'form',
|
||||
'view_type': 'form',
|
||||
'res_model': 'stock.picking',
|
||||
'res_id':self.picking_id.id,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target':'current',
|
||||
}
|
||||
|
||||
def action_available_qty(self):
|
||||
for rec in self:
|
||||
if not rec.location_id:
|
||||
raise ValidationError(_("Please Insert Location first"))
|
||||
for line in rec.line_ids:
|
||||
line.available_qty = self.env['stock.quant'].search(
|
||||
[('product_id', '=', line.product_id.id), ('location_id', '=', rec.location_id.id)],
|
||||
limit=1).available_quantity
|
||||
line.qty_purchased=line.qty-line.available_qty
|
||||
|
||||
|
||||
|
||||
class PurchaseRequestLine(models.Model):
|
||||
_inherit = 'purchase.request.line'
|
||||
_description = 'purchase request line'
|
||||
|
||||
qty_purchased = fields.Integer(string='Purchase Qty')
|
||||
qty = fields.Integer(string='Demand Qty')
|
||||
available_qty = fields.Integer(string='Available Qty')
|
||||
|
||||
|
||||
@api.constrains('qty')
|
||||
def qty_validation(self):
|
||||
for rec in self:
|
||||
if rec.qty <= 0:
|
||||
raise ValidationError(_("Item Quantity MUST be at Least ONE!"))
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
|
||||
model_convert_picking_wizard_user,picking_wizard,model_purchase_request_picking_wizard,base.group_user,1,1,1,1
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- purchase.request form view -->
|
||||
<record id="purchase_request_form_inherit" model="ir.ui.view">
|
||||
<field name="name">purchase.request.view.form</field>
|
||||
<field name="model">purchase.request</field>
|
||||
<field name="inherit_id" ref="purchase_requisition_custom.purchase_request_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/header/button[@name='action_done']" position="replace">
|
||||
<button name="action_done" type="object" string="Delivery Done" class="oe_highlight"
|
||||
groups="purchase_requisition_custom.create_purchase_request" attrs="{'invisible':[('show_emp_button' , '=' , False)]}" />
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='use_analytic']" position="attributes">
|
||||
<attribute name="attrs">{'readonly':[('state','!=','draft')]}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//group[1]" position="after">
|
||||
<group col="2" colspan="2">
|
||||
<field name="view_location_id" invisible="1"/>
|
||||
<field name="edit_locations" invisible="1"/>
|
||||
<field name="show_emp_button" invisible="1"/>
|
||||
<div>
|
||||
<label for="warehouse_id"/>
|
||||
<field name="warehouse_id" attrs="{'readonly':['|',('edit_locations' , '=' , False),('state' , '!=' , 'warehouse')]}" groups="stock.group_stock_user,stock.group_stock_manager"/>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<label for="location_id"/>
|
||||
<field name="location_id" attrs="{'readonly':['|',('edit_locations' , '=' , False),('state' , '!=' , 'warehouse')]}" groups="stock.group_stock_user,stock.group_stock_manager" />
|
||||
|
||||
</div>
|
||||
</group>
|
||||
</xpath>
|
||||
<xpath expr="//button[@name='open_requisition']" position="after">
|
||||
<field name="picking_id" invisible="1"/>
|
||||
<button class="oe_stat_button" name="open_picking" type="object"
|
||||
string="Delivery" icon="fa-list-ol"
|
||||
attrs="{'invisible' : [('picking_id' , '=' ,False)]}"
|
||||
groups="purchase.group_purchase_user,purchase.group_purchase_manager"/>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//button[@name='action_confirm']" position="after">
|
||||
<button name="action_confirm_picking"
|
||||
type="object" string="Confirm" states="warehouse" class="oe_highlight" groups="stock.group_stock_user,stock.group_stock_manager"/>
|
||||
<button name="action_available_qty"
|
||||
type="object" string="Available Quantity" states="warehouse" class="oe_highlight" groups="stock.group_stock_user,stock.group_stock_manager"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='line_ids']/tree[1]/field[@name='qty']" position="after">
|
||||
<field name="available_qty" readonly="1" attrs="{'column_invisible': [('parent.state', '!=', 'warehouse')]}"/>
|
||||
<field name="qty_purchased" readonly="1" attrs="{'column_invisible': [('parent.state', '!=', 'waiting')]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- purchase.request tree view -->
|
||||
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1 @@
|
|||
from . import picking_purchase_request
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class PurcahseRefues(models.TransientModel):
|
||||
|
||||
|
||||
_name = "purchase.request_picking.wizard"
|
||||
_description = "purchase Checking Options wizard"
|
||||
|
||||
request_id = fields.Many2one('purchase.request')
|
||||
request_line_ids = fields.Many2many('purchase.request.line')
|
||||
is_available=fields.Boolean("Available")
|
||||
|
||||
|
||||
def delivery_close(self):
|
||||
picking_vals = {
|
||||
"picking_type_id": self.env.ref('purchase_custom_stock.stock_picking_type_stock').id,
|
||||
"origin": self.request_id.name,
|
||||
"location_id": self.request_id.location_id.id,
|
||||
"location_dest_id": self.request_id.picking_type_id.default_location_dest_id.id
|
||||
}
|
||||
|
||||
move_vals = []
|
||||
for line in self.request_line_ids:
|
||||
move_vals.append((0, 0, {
|
||||
"product_id": line.product_id.id,
|
||||
"name": line.product_id.name,
|
||||
"product_uom": line.product_id.uom_id.id,
|
||||
'product_uom_qty': line.available_qty,
|
||||
|
||||
}))
|
||||
picking_vals.update({'move_lines': move_vals})
|
||||
picking_id = self.env['stock.picking'].create(picking_vals)
|
||||
self.request_id.picking_id = picking_id.id
|
||||
self.request_id.write({'state': 'employee'})
|
||||
|
||||
def delivery_purchase(self):
|
||||
picking_vals = {
|
||||
"picking_type_id": self.env.ref('purchase_custom_stock.stock_picking_type_stock').id,
|
||||
"origin": self.request_id.name,
|
||||
"location_id": self.request_id.location_id.id,
|
||||
"location_dest_id": self.request_id.picking_type_id.default_location_dest_id.id
|
||||
}
|
||||
|
||||
move_vals = []
|
||||
for line in self.request_line_ids:
|
||||
move_vals.append((0, 0, {
|
||||
"product_id": line.product_id.id,
|
||||
"name": line.product_id.name,
|
||||
"product_uom": line.product_id.uom_id.id,
|
||||
'product_uom_qty': line.available_qty,
|
||||
}))
|
||||
line.qty_purchased=line.qty
|
||||
picking_vals.update({'move_lines': move_vals})
|
||||
picking_id = self.env['stock.picking'].create(picking_vals)
|
||||
for line in self.request_line_ids:
|
||||
line.qty_purchased=line.qty-line.available_qty
|
||||
self.request_id.picking_id = picking_id.id
|
||||
self.request_id.write({'state': 'waiting'})
|
||||
def convert_purchase(self):
|
||||
for line in self.request_line_ids:
|
||||
line.qty_purchased=line.qty
|
||||
self.request_id.write({'state': 'waiting'})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="purchase_request_picking_wizard_view_form" model="ir.ui.view">
|
||||
<field name="name">purchase.request_picking.wizard.form</field>
|
||||
<field name="model">purchase.request_picking.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Cancel Request Reason">
|
||||
<field name="request_id" invisible="1"/>
|
||||
<field name="is_available" invisible="1"/>
|
||||
|
||||
<footer>
|
||||
<button string='Delivery and Close' attrs="{'invisible':[('is_available' , '=' , False)]}" name="delivery_close" type="object" class="oe_highlight"/>
|
||||
<button string='Delivery and Purchase' attrs="{'invisible':[('is_available' , '=' , False)]}" name="delivery_purchase" type="object" class="oe_highlight"/>
|
||||
<button string='Convert Purchase' name="convert_purchase" type="object" class="oe_highlight"/>
|
||||
<button string="Cancel" class="oe_link" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="purchase_request_picking_wizard_action" model="ir.actions.act_window">
|
||||
<field name="name">Picking Options Request</field>
|
||||
<field name="res_model">purchase.request_picking.wizard</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="purchase_request_picking_wizard_view_form"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Loading…
Reference in New Issue