Accept Merge Request #1820: (feature/合同审批 -> develop)
Merge Request: 采购协议 Created By: @管欢 Reviewed By: @胡尧 Approved By: @胡尧 Accepted By: @管欢 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1820
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from . import controllers
|
|
||||||
from . import models
|
from . import models
|
||||||
from . import wizards
|
from . import wizards
|
||||||
|
|||||||
@@ -24,9 +24,6 @@
|
|||||||
|
|
||||||
# always loaded
|
# always loaded
|
||||||
'data': [
|
'data': [
|
||||||
'security/ir.model.access.csv',
|
|
||||||
'data/documents_data.xml',
|
|
||||||
'wizards/upload_file_wizard_view.xml',
|
|
||||||
'views/views.xml',
|
'views/views.xml',
|
||||||
],
|
],
|
||||||
# only loaded in demonstration mode
|
# only loaded in demonstration mode
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from . import controllers
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# from odoo import http
|
|
||||||
|
|
||||||
|
|
||||||
# class JikimoPurchaseTierValidation(http.Controller):
|
|
||||||
# @http.route('/jikimo_purchase_tier_validation/jikimo_purchase_tier_validation', auth='public')
|
|
||||||
# def index(self, **kw):
|
|
||||||
# return "Hello, world"
|
|
||||||
|
|
||||||
# @http.route('/jikimo_purchase_tier_validation/jikimo_purchase_tier_validation/objects', auth='public')
|
|
||||||
# def list(self, **kw):
|
|
||||||
# return http.request.render('jikimo_purchase_tier_validation.listing', {
|
|
||||||
# 'root': '/jikimo_purchase_tier_validation/jikimo_purchase_tier_validation',
|
|
||||||
# 'objects': http.request.env['jikimo_purchase_tier_validation.jikimo_purchase_tier_validation'].search([]),
|
|
||||||
# })
|
|
||||||
|
|
||||||
# @http.route('/jikimo_purchase_tier_validation/jikimo_purchase_tier_validation/objects/<model("jikimo_purchase_tier_validation.jikimo_purchase_tier_validation"):obj>', auth='public')
|
|
||||||
# def object(self, obj, **kw):
|
|
||||||
# return http.request.render('jikimo_purchase_tier_validation.object', {
|
|
||||||
# 'object': obj
|
|
||||||
# })
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<data noupdate="1">
|
|
||||||
<!-- 创建采购合同文件夹 -->
|
|
||||||
<record id="documents_purchase_contracts_folder" model="documents.folder">
|
|
||||||
<field name="name">采购合同</field>
|
|
||||||
<field name="description">存放采购合同相关文件</field>
|
|
||||||
<field name="sequence">10</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<!--
|
|
||||||
<record id="object0" model="jikimo_purchase_tier_validation.jikimo_purchase_tier_validation">
|
|
||||||
<field name="name">Object 0</field>
|
|
||||||
<field name="value">0</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="object1" model="jikimo_purchase_tier_validation.jikimo_purchase_tier_validation">
|
|
||||||
<field name="name">Object 1</field>
|
|
||||||
<field name="value">10</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="object2" model="jikimo_purchase_tier_validation.jikimo_purchase_tier_validation">
|
|
||||||
<field name="name">Object 2</field>
|
|
||||||
<field name="value">20</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="object3" model="jikimo_purchase_tier_validation.jikimo_purchase_tier_validation">
|
|
||||||
<field name="name">Object 3</field>
|
|
||||||
<field name="value">30</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="object4" model="jikimo_purchase_tier_validation.jikimo_purchase_tier_validation">
|
|
||||||
<field name="name">Object 4</field>
|
|
||||||
<field name="value">40</field>
|
|
||||||
</record>
|
|
||||||
-->
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
@@ -21,12 +21,8 @@ class jikimo_purchase_tier_validation(models.Model):
|
|||||||
|
|
||||||
def button_confirm(self):
|
def button_confirm(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
# if record.need_validation and record.validation_status != 'validated':
|
|
||||||
# raise ValidationError(_('此操作需要至少对一条记录进行审批。\n请发起审批申请。'))
|
|
||||||
if record.state in ['to approve']:
|
if record.state in ['to approve']:
|
||||||
raise ValidationError(_('请先完成审批。'))
|
raise ValidationError(_('请先完成审批。'))
|
||||||
# if record.state == 'approved':
|
|
||||||
# record.state = 'purchase'
|
|
||||||
res = super(jikimo_purchase_tier_validation, self).button_confirm()
|
res = super(jikimo_purchase_tier_validation, self).button_confirm()
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.state == 'approved':
|
if record.state == 'approved':
|
||||||
@@ -39,45 +35,8 @@ class jikimo_purchase_tier_validation(models.Model):
|
|||||||
record.message_subscribe([record.partner_id.id])
|
record.message_subscribe([record.partner_id.id])
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# def button_confirm(self):
|
|
||||||
# self = self.with_context(skip_validation=True)
|
|
||||||
# return super().button_confirm()
|
|
||||||
#
|
|
||||||
# def _check_state_conditions(self, vals):
|
|
||||||
# self.ensure_one()
|
|
||||||
# if self._context.get('skip_validation'):
|
|
||||||
# return False
|
|
||||||
# return (
|
|
||||||
# self._check_state_from_condition()
|
|
||||||
# and vals.get(self._state_field) in self._state_to
|
|
||||||
# )
|
|
||||||
|
|
||||||
def request_validation(self):
|
def request_validation(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
error_messages = []
|
|
||||||
|
|
||||||
# 检查必填字段
|
|
||||||
required_fields = {
|
|
||||||
'partner_ref': '合同名称',
|
|
||||||
'contract_number': '合同编号'
|
|
||||||
}
|
|
||||||
|
|
||||||
missing_fields = [
|
|
||||||
name for field, name in required_fields.items()
|
|
||||||
if not record[field]
|
|
||||||
]
|
|
||||||
|
|
||||||
if missing_fields:
|
|
||||||
error_messages.append('* 如下字段要求必须填写:%s' % '、'.join(missing_fields))
|
|
||||||
|
|
||||||
# 检查合同文件
|
|
||||||
if not record.contract_document_id:
|
|
||||||
error_messages.append('* 必须点击上传合同文件')
|
|
||||||
|
|
||||||
# 如果有任何错误,一次性显示所有错误信息
|
|
||||||
if error_messages:
|
|
||||||
raise ValidationError('\n'.join(error_messages))
|
|
||||||
|
|
||||||
# 添加通知消息
|
# 添加通知消息
|
||||||
if hasattr(record, 'message_post'):
|
if hasattr(record, 'message_post'):
|
||||||
current_user = self.env.user.name
|
current_user = self.env.user.name
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
|
||||||
access_ir_attachment_wizard,ir.attachment.wizard,model_ir_attachment_wizard,base.group_user,1,1,1,1
|
|
||||||
|
@@ -1,24 +0,0 @@
|
|||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<!--
|
|
||||||
<template id="listing">
|
|
||||||
<ul>
|
|
||||||
<li t-foreach="objects" t-as="object">
|
|
||||||
<a t-attf-href="#{ root }/objects/#{ object.id }">
|
|
||||||
<t t-esc="object.display_name"/>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</template>
|
|
||||||
<template id="object">
|
|
||||||
<h1><t t-esc="object.display_name"/></h1>
|
|
||||||
<dl>
|
|
||||||
<t t-foreach="object._fields" t-as="field">
|
|
||||||
<dt><t t-esc="field"/></dt>
|
|
||||||
<dd><t t-esc="object[field]"/></dd>
|
|
||||||
</t>
|
|
||||||
</dl>
|
|
||||||
</template>
|
|
||||||
-->
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
@@ -23,76 +23,10 @@
|
|||||||
<xpath expr="//header/field[@name='state']" position="replace">
|
<xpath expr="//header/field[@name='state']" position="replace">
|
||||||
<field name="state" widget="statusbar" statusbar_visible="draft,sent,to approve, approved, purchase" readonly="1"/>
|
<field name="state" widget="statusbar" statusbar_visible="draft,sent,to approve, approved, purchase" readonly="1"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
|
|
||||||
<xpath expr="//header/button[last()]" position="after">
|
<xpath expr="//header/button[last()]" position="after">
|
||||||
<button name="button_cancel" states="draft,to approve,sent,purchase" string="取消" type="object" data-hotkey="x" />
|
<button name="button_cancel" states="draft,to approve,sent,purchase" string="取消" type="object" data-hotkey="x" />
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
<xpath expr="//header/button[@name='action_rfq_send'][1]" position="before">
|
|
||||||
<field name="validation_status" invisible="1"/>
|
|
||||||
<field name="is_upload_contract_file" invisible="1"/>
|
|
||||||
<button name="upload_contract_file" string="上传合同" type="object" class="oe_highlight" attrs="{'invisible': ['|', '|', ('validation_status', '!=', 'no'), ('is_upload_contract_file', '=', True), ('state', 'not in', ['draft', 'sent'])]}"/>]}"/>
|
|
||||||
<button name="delete_contract_file" string="删除合同" type="object" class="oe_highlight" attrs="{'invisible': ['|', ('validation_status', '!=', 'no'), ('is_upload_contract_file', '=', False)]}"/>
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//notebook/page[1]" position="before">
|
|
||||||
<page string="合同" name="contract_documents"
|
|
||||||
attrs="{'invisible': [('contract_document_id', '=', False)]}"
|
|
||||||
autofocus="autofocus">
|
|
||||||
<group>
|
|
||||||
<group>
|
|
||||||
<field name="contract_document_id" invisible="1"/>
|
|
||||||
<field name="contract_file_name" invisible="1"/>
|
|
||||||
<field name="contract_file"
|
|
||||||
widget="adaptive_viewer"
|
|
||||||
filename="contract_file_name"/>
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
</page>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- actions opening views on models -->
|
|
||||||
<!--
|
|
||||||
<record model="ir.actions.act_window" id="jikimo_purchase_tier_validation.action_window">
|
|
||||||
<field name="name">jikimo_purchase_tier_validation window</field>
|
|
||||||
<field name="res_model">jikimo_purchase_tier_validation.jikimo_purchase_tier_validation</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
|
||||||
</record>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- server action to the one above -->
|
|
||||||
<!--
|
|
||||||
<record model="ir.actions.server" id="jikimo_purchase_tier_validation.action_server">
|
|
||||||
<field name="name">jikimo_purchase_tier_validation server</field>
|
|
||||||
<field name="model_id" ref="model_jikimo_purchase_tier_validation_jikimo_purchase_tier_validation"/>
|
|
||||||
<field name="state">code</field>
|
|
||||||
<field name="code">
|
|
||||||
action = {
|
|
||||||
"type": "ir.actions.act_window",
|
|
||||||
"view_mode": "tree,form",
|
|
||||||
"res_model": model._name,
|
|
||||||
}
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- Top menu item -->
|
|
||||||
<!--
|
|
||||||
<menuitem name="jikimo_purchase_tier_validation" id="jikimo_purchase_tier_validation.menu_root"/>
|
|
||||||
-->
|
|
||||||
<!-- menu categories -->
|
|
||||||
<!--
|
|
||||||
<menuitem name="Menu 1" id="jikimo_purchase_tier_validation.menu_1" parent="jikimo_purchase_tier_validation.menu_root"/>
|
|
||||||
<menuitem name="Menu 2" id="jikimo_purchase_tier_validation.menu_2" parent="jikimo_purchase_tier_validation.menu_root"/>
|
|
||||||
-->
|
|
||||||
<!-- actions -->
|
|
||||||
<!--
|
|
||||||
<menuitem name="List" id="jikimo_purchase_tier_validation.menu_1_list" parent="jikimo_purchase_tier_validation.menu_1"
|
|
||||||
action="jikimo_purchase_tier_validation.action_window"/>
|
|
||||||
<menuitem name="Server to list" id="jikimo_purchase_tier_validation" parent="jikimo_purchase_tier_validation.menu_2"
|
|
||||||
action="jikimo_purchase_tier_validation.action_server"/>
|
|
||||||
-->
|
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -1,2 +1 @@
|
|||||||
from . import upload_file_wizard
|
|
||||||
from . import comment_wizard
|
from . import comment_wizard
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
from odoo import models, fields, api, _
|
|
||||||
|
|
||||||
|
|
||||||
class IrAttachmentWizard(models.TransientModel):
|
|
||||||
_name = 'ir.attachment.wizard'
|
|
||||||
_description = '文件上传向导'
|
|
||||||
|
|
||||||
attachment = fields.Binary(string='选择文件', required=True)
|
|
||||||
filename = fields.Char(string='文件名')
|
|
||||||
res_model = fields.Char()
|
|
||||||
res_id = fields.Integer()
|
|
||||||
|
|
||||||
# def action_upload_file(self):
|
|
||||||
# self.ensure_one()
|
|
||||||
# # 首先创建 ir.attachment
|
|
||||||
# attachment = self.env['ir.attachment'].create({
|
|
||||||
# 'name': self.filename,
|
|
||||||
# 'type': 'binary',
|
|
||||||
# 'datas': self.attachment,
|
|
||||||
# 'res_model': self.res_model,
|
|
||||||
# 'res_id': self.res_id,
|
|
||||||
# })
|
|
||||||
#
|
|
||||||
# # 获取默认的文档文件夹
|
|
||||||
# workspace = self.env['documents.folder'].search([('name', '=', '采购合同')], limit=1)
|
|
||||||
#
|
|
||||||
# # 创建 documents.document 记录
|
|
||||||
# document = self.env['documents.document'].create({
|
|
||||||
# 'name': self.filename,
|
|
||||||
# 'attachment_id': attachment.id,
|
|
||||||
# 'folder_id': workspace.id,
|
|
||||||
# 'res_model': self.res_model,
|
|
||||||
# 'res_id': self.res_id,
|
|
||||||
# })
|
|
||||||
#
|
|
||||||
# return {
|
|
||||||
# 'type': 'ir.actions.client',
|
|
||||||
# 'tag': 'display_notification',
|
|
||||||
# 'params': {
|
|
||||||
# 'title': _('成功'),
|
|
||||||
# 'message': _('文件上传成功'),
|
|
||||||
# 'type': 'success',
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
def action_upload_file(self):
|
|
||||||
self.ensure_one()
|
|
||||||
# 获取当前用户的 partner_id
|
|
||||||
current_partner = self.env.user.partner_id
|
|
||||||
# 首先创建 ir.attachment
|
|
||||||
attachment = self.env['ir.attachment'].create({
|
|
||||||
'name': self.filename,
|
|
||||||
'type': 'binary',
|
|
||||||
'datas': self.attachment,
|
|
||||||
'res_model': self.res_model,
|
|
||||||
'res_id': self.res_id,
|
|
||||||
})
|
|
||||||
|
|
||||||
# 获取默认的文档文件夹
|
|
||||||
workspace = self.env['documents.folder'].search([('name', '=', '采购合同')], limit=1)
|
|
||||||
|
|
||||||
# 创建 documents.document 记录
|
|
||||||
document = self.env['documents.document'].create({
|
|
||||||
'name': self.filename,
|
|
||||||
'attachment_id': attachment.id,
|
|
||||||
'folder_id': workspace.id,
|
|
||||||
'res_model': self.res_model,
|
|
||||||
'res_id': self.res_id,
|
|
||||||
'partner_id': current_partner.id,
|
|
||||||
})
|
|
||||||
|
|
||||||
# 更新采购订单的合同文档字段
|
|
||||||
purchase_order = self.env['purchase.order'].browse(self.res_id)
|
|
||||||
purchase_order.write({
|
|
||||||
'contract_document_id': document.id,
|
|
||||||
'is_upload_contract_file': True
|
|
||||||
})
|
|
||||||
|
|
||||||
# 显示成功消息并关闭向导
|
|
||||||
message = {
|
|
||||||
'type': 'ir.actions.client',
|
|
||||||
'tag': 'display_notification',
|
|
||||||
'params': {
|
|
||||||
'title': _('成功'),
|
|
||||||
'message': _('文件上传成功'),
|
|
||||||
'type': 'success',
|
|
||||||
'sticky': False, # 自动消失
|
|
||||||
'next': {
|
|
||||||
'type': 'ir.actions.act_window_close'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return message
|
|
||||||
|
|
||||||
|
|
||||||
# def action_upload_file(self):
|
|
||||||
# self.ensure_one()
|
|
||||||
# attachment = self.env['ir.attachment'].create({
|
|
||||||
# 'name': self.filename,
|
|
||||||
# 'type': 'binary',
|
|
||||||
# 'datas': self.attachment,
|
|
||||||
# 'res_model': self.res_model,
|
|
||||||
# 'res_id': self.res_id,
|
|
||||||
# })
|
|
||||||
# return {
|
|
||||||
# 'type': 'ir.actions.client',
|
|
||||||
# 'tag': 'display_notification',
|
|
||||||
# 'params': {
|
|
||||||
# 'title': _('成功'),
|
|
||||||
# 'message': _('文件上传成功'),
|
|
||||||
# 'type': 'success',
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<record id="view_upload_file_wizard_form" model="ir.ui.view">
|
|
||||||
<field name="name">ir.attachment.wizard.form</field>
|
|
||||||
<field name="model">ir.attachment.wizard</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<form string="上传文件">
|
|
||||||
<group>
|
|
||||||
<field name="attachment" widget="binary" filename="filename" options="{'accepted_file_extensions': '.pdf,.doc,.docx,.jpg,.jpeg,.png'}"/>
|
|
||||||
<field name="filename" invisible="1"/>
|
|
||||||
<field name="res_model" invisible="1"/>
|
|
||||||
<field name="res_id" invisible="1"/>
|
|
||||||
</group>
|
|
||||||
<footer>
|
|
||||||
<button name="action_upload_file" string="确认上传" type="object" class="btn-primary"/>
|
|
||||||
<button string="取消" class="btn-secondary" special="cancel"/>
|
|
||||||
</footer>
|
|
||||||
</form>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</odoo>
|
|
||||||
@@ -139,7 +139,7 @@
|
|||||||
</field>
|
</field>
|
||||||
<xpath expr="//field[@name='date_order']" position="after">
|
<xpath expr="//field[@name='date_order']" position="after">
|
||||||
<field name="payment_term_id" attrs="{'readonly': ['|', ('invoice_status','=', 'invoiced'), ('state', '=', 'done')]}" options="{'no_create': True}"/>
|
<field name="payment_term_id" attrs="{'readonly': ['|', ('invoice_status','=', 'invoiced'), ('state', '=', 'done')]}" options="{'no_create': True}"/>
|
||||||
<field name="contract_summary"/>
|
<!-- <field name="contract_summary"/>-->
|
||||||
</xpath>
|
</xpath>
|
||||||
<field name="partner_ref" position="attributes">
|
<field name="partner_ref" position="attributes">
|
||||||
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
|
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
|
||||||
|
|||||||
Reference in New Issue
Block a user