提交 a05f8190 authored 作者: 伍姿英's avatar 伍姿英

Merge branch 'release/3.0.0'

......@@ -31,6 +31,7 @@
'views/cc_node_view.xml',
'views/cc_ship_package_view.xml',
'views/cc_bl_view.xml',
'views/pda_scan_record_views.xml',
],
'demo': [
......
......@@ -8,6 +8,7 @@ from . import cc_node
from . import cc_bill_loading
from . import ir_attachment
from . import http
from . import pda_scan_record
# -*- coding: utf-8 -*-
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
class PDAScanRecord(models.Model):
_name = 'pda.scan.record'
_description = _('PDA Scan Record') # PDA扫码记录
_order = 'create_date desc'
_rec_name = 'bill_number'
@api.onchange('operation')
def _onchange_operation(self):
"""根据操作自动设置类型"""
if self.operation:
if 'tally' in self.operation:
self.record_type = 'tally'
elif 'handover' in self.operation:
self.record_type = 'handover'
operator_id = fields.Many2one('res.users', string='操作人', required=True)
operation_time = fields.Datetime(string='操作时间', required=True, default=fields.Datetime.now)
operation = fields.Selection([
('bill_tally', _('Bill Tally')), # 按提单理货
('tail_tally', _('Tail Tally')), # 按尾程理货
('bill_handover', _('Bill Handover')), # 按提单交货
('tail_handover', _('Tail Handover')) # 按尾程交货
], string=_('Operation'), required=True) # 操作
record_type = fields.Selection([
('tally', _('Tally')), # 理货
('handover', _('Handover')) # 交货
], string=_('Type'), required=True) # 类型
bill_number = fields.Char(string=_('Bill Number')) # 提单号
transfer_number = fields.Char(string=_('Transfer Number')) # 转运单号
# 增加提单关联字段
bl_id = fields.Many2one('cc.bl', string=_('Bill of Lading'), ondelete='cascade') # 提单对象
#增加状态 成功 失败
state = fields.Selection([
('success', _('Success')),
('failed', _('Failed'))
], string=_('State'), required=True)
failure_reason = fields.Char(string=_('Failure Reason')) # 失败原因
@api.model
def create_scan_record(self, operation, record_type, bill_number, transfer_number, state, operator_id=False, bl_id=False, failure_reason=False, operation_time=False):
"""
创建扫码记录的方法,供接口调用
Create scan record method for API calls
"""
try:
if not operator_id:
operator_id = self.env['res.users'].search([('login', '=', 'pda')], limit=1).id
# 如果没有传入bl_id,根据bill_number查找提单对象
if not bl_id and bill_number:
bl_obj = self.env['cc.bl'].sudo().deal_bl_no_and_transfer_bl_no(bill_number)
if bl_obj:
bl_id = bl_obj.id
# 准备创建记录的数据
record_data = {
'operator_id': operator_id,
'operation': operation,
'record_type': record_type,
'bill_number': bill_number,
'transfer_number': transfer_number,
'bl_id': bl_id,
'state': state,
'failure_reason': failure_reason
}
# 如果传入了自定义操作时间,使用它
if operation_time:
record_data['operation_time'] = operation_time
record = self.create(record_data)
return {
'success': True,
'record_id': record.id,
'message': ''
}
except Exception as e:
return {
'success': False,
'message': _('Creation failed: %s') % str(e) # 创建失败
}
\ No newline at end of file
......@@ -15,6 +15,8 @@ class ResConfigSettings(models.TransientModel):
tt_app_secret = fields.Char('AppSecret', default='')
tt_version = fields.Char('接口版本', default='3.0')
tt_customer_id = fields.Many2one('res.partner', string='客户')
#交货操作晚于提货操作X分钟【默认80分钟】
delivery_time = fields.Integer('交货操作晚于提货操作X分钟', default=80,config_parameter='delivery_time')
@api.model
def get_values(self):
......@@ -29,13 +31,15 @@ class ResConfigSettings(models.TransientModel):
tt_app_secret = config.get_param('tt_app_secret', default='')
tt_version = config.get_param('tt_version', default='')
tt_customer_id = config.get_param('tt_customer_id', default=False)
delivery_time = config.get_param('delivery_time', default=80)
customer = self.env['res.partner'].sudo().search([('id', '=', tt_customer_id)])
values.update(
tt_url=tt_url,
tt_app_key=tt_app_key,
tt_app_secret=tt_app_secret,
tt_version=tt_version,
tt_customer_id=customer
tt_customer_id=customer,
delivery_time=delivery_time
)
return values
......@@ -47,3 +51,4 @@ class ResConfigSettings(models.TransientModel):
ir_config.set_param("tt_app_secret", self.tt_app_secret or "")
ir_config.set_param("tt_version", self.tt_version or "")
ir_config.set_param("tt_customer_id", self.tt_customer_id.id or False)
ir_config.set_param("delivery_time", self.delivery_time or 80)
\ No newline at end of file
......@@ -12,3 +12,6 @@ access_cc_bl_sync_log_base.group_erp_manager,cc_bl_sync_log base.group_erp_manag
access_cc_bl_sync_log_ccs_base.group_clearance_of_customs_manager,cc_bl_sync_log ccs_base.group_clearance_of_customs_manager,ccs_connect_tiktok.model_cc_bl_sync_log,ccs_base.group_clearance_of_customs_manager,1,0,0,0
access_cc_bl_sync_log_ccs_base.group_clearance_of_customs_user,cc_bl_sync_log ccs_base.group_clearance_of_customs_user,ccs_connect_tiktok.model_cc_bl_sync_log,ccs_base.group_clearance_of_customs_user,1,0,0,0
access_pda_scan_record_user,pda.scan.record.user,model_pda_scan_record,base.group_user,1,1,1,0
access_pda_scan_record_manager,pda.scan.record.manager,model_pda_scan_record,base.group_system,1,1,1,1
......@@ -25,6 +25,10 @@
<label for="tt_customer_id"/>
<field name="tt_customer_id"/>
</div>
<div class="text-muted">
<label for="delivery_time"/>
<field name="delivery_time"/>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
......
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- PDA扫码记录列表视图 -->
<record id="view_pda_scan_record_tree" model="ir.ui.view">
<field name="name">pda.scan.record.tree</field>
<field name="model">pda.scan.record</field>
<field name="arch" type="xml">
<tree string="PDA Scan Record" decoration-info="state == 'success'" decoration-danger="state == 'failed'">
<field name="operator_id" />
<field name="operation_time"/>
<field name="operation"/>
<field name="record_type"/>
<field name="bill_number"/>
<field name="transfer_number"/>
<field name="bl_id" invisible="1"/>
<field name="state"/>
<field name="failure_reason" optional="hide"/>
</tree>
</field>
</record>
<!-- PDA扫码记录表单视图 -->
<record id="view_pda_scan_record_form" model="ir.ui.view">
<field name="name">pda.scan.record.form</field>
<field name="model">pda.scan.record</field>
<field name="arch" type="xml">
<form string="PDA Scan Record">
<header>
<field name="state" widget="statusbar"/>
</header>
<sheet>
<group>
<group>
<field name="operator_id" />
<field name="operation_time"/>
<field name="operation"/>
</group>
<group>
<field name="record_type"/>
<field name="bl_id" invisible="1"/>
<field name="bill_number"/>
<field name="transfer_number"/>
</group>
</group>
<group>
<field name="failure_reason" attrs="{'invisible': [('state', '=', 'success')]}" />
</group>
</sheet>
</form>
</field>
</record>
<!-- PDA扫码记录搜索视图 -->
<record id="view_pda_scan_record_search" model="ir.ui.view">
<field name="name">pda.scan.record.search</field>
<field name="model">pda.scan.record</field>
<field name="arch" type="xml">
<search string="PDA Scan Record">
<field name="operator_id"/>
<field name="operation_time"/>
<field name="operation"/>
<field name="record_type"/>
<field name="bill_number"/>
<field name="transfer_number"/>
<filter string="Tally" name="tally" domain="[('record_type', '=', 'tally')]"/>
<filter string="Handover" name="handover" domain="[('record_type', '=', 'handover')]"/>
</search>
</field>
</record>
<!-- PDA扫码记录动作 -->
<record id="action_pda_scan_record" model="ir.actions.act_window">
<field name="name">PDA Scan Record</field>
<field name="res_model">pda.scan.record</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_pda_scan_record_search"/>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create your first PDA scan record
</p>
</field>
</record>
<!-- 菜单项 -->
<menuitem id="menu_pda_scan_record"
name="PDA Scan Record"
action="action_pda_scan_record"
sequence="21"/>
</odoo>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论