提交 1c838c27 authored 作者: 贺阳's avatar 贺阳

1、小包状态增加sns

2、提单变更状态增加查询已有节点更新的小包
上级 f594f246
......@@ -13,7 +13,7 @@
""",
'category': 'Clearance of customs',
'website': 'https://www.yizuo.ltd',
'depends': ['base','mail','web'],
'depends': ['base', 'mail', 'web'],
'data': [
'security/account_security.xml',
'security/ir.model.access.csv',
......@@ -28,7 +28,7 @@
'views/cc_big_package_view.xml',
'views/cc_node_exception_reason_view.xml',
'views/cc_bl_view.xml',
#'views/cc_customers_declaration_order_view.xml',
# 'views/cc_customers_declaration_order_view.xml',
'templates/login.xml',
],
'demo': [
......
......@@ -3,4 +3,5 @@ from . import cc_node
from . import cc_bill_loading
from . import cc_customs_declaration_order
from . import cc_node_exception_reason
from . import mail_thread
......@@ -318,11 +318,11 @@ class CcShipPackage(models.Model):
string='Invoice Attachments')
# 进度状态, 包括已提货、 小包查验、海关放行、小包出库、小包入库、清关失败,包裹交接
state = fields.Many2one('cc.node', string='Progress state', domain="[('node_type', '=', 'package')]",
state = fields.Many2one('cc.node', string='Progress state', domain="[('node_type', '=', 'package')]", tracking=True,
default=lambda self: self.env['cc.node'].search(
[('node_type', '=', 'package'), ('is_default', '=', True)], limit=1))
node_exception_reason_id = fields.Many2one('cc.node.exception.reason', 'Exception Reason')
process_time = fields.Datetime('Process Time(UTC)')
process_time = fields.Datetime('Process Time')
# 重载write方法,在进度状态变化时,将is_sync置为False, 同时检查is_sync为false时,不允许修改进度状态
def write(self, vals):
......
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import ast
import base64
import datetime
import dateutil
import email
import email.policy
import hashlib
import hmac
import json
import lxml
import logging
import pytz
import re
import time
import threading
from collections import namedtuple
from email.message import EmailMessage
from email import message_from_string
from lxml import etree
from werkzeug import urls
from xmlrpc import client as xmlrpclib
from markupsafe import Markup
from odoo import _, api, exceptions, fields, models, tools, registry, SUPERUSER_ID, Command
from odoo.exceptions import MissingError, AccessError
from odoo.osv import expression
from odoo.tools import is_html_empty
from odoo.tools.misc import clean_context, split_every
_logger = logging.getLogger(__name__)
class MailThread(models.AbstractModel):
''' mail_thread model is meant to be inherited by any model that needs to
act as a discussion topic on which messages can be attached. Public
methods are prefixed with ``message_`` in order to avoid name
collisions with methods of the models that will inherit from this class.
``mail.thread`` defines fields used to handle and display the
communication history. ``mail.thread`` also manages followers of
inheriting classes. All features and expected behavior are managed
by mail.thread. Widgets has been designed for the 7.0 and following
versions of Odoo.
Inheriting classes are not required to implement any method, as the
default implementation will work for any model. However it is common
to override at least the ``message_new`` and ``message_update``
methods (calling ``super``) to add model-specific behavior at
creation and update of a thread when processing incoming emails.
Options:
- _mail_flat_thread: if set to True, all messages without parent_id
are automatically attached to the first message posted on the
resource. If set to False, the display of Chatter is done using
threads, and no parent_id is automatically set.
MailThread features can be somewhat controlled through context keys :
- ``mail_create_nosubscribe``: at create or message_post, do not subscribe
uid to the record thread
- ``mail_create_nolog``: at create, do not log the automatic '<Document>
created' message
- ``mail_notrack``: at create and write, do not perform the value tracking
creating messages
- ``tracking_disable``: at create and write, perform no MailThread features
(auto subscription, tracking, post, ...)
- ``mail_notify_force_send``: if less than 50 email notifications to send,
send them directly instead of using the queue; True by default
'''
_inherit = 'mail.thread'
_description = 'Email Thread'
def _message_compute_author(self, author_id=None, email_from=None, raise_on_email=True):
""" Tool method computing author information for messages. Purpose is
to ensure maximum coherence between author / current user / email_from
when sending emails.
:param raise_on_email: if email_from is not found, raise an UserError
:return tuple: res.partner ID (may be False or None), email_from
"""
if author_id is None:
if email_from:
author = self._mail_find_partner_from_emails([email_from])[0]
else:
author = self.env.user.partner_id
email_from = author.email_formatted
author_id = author.id
if email_from is None:
if author_id:
author = self.env['res.partner'].browse(author_id)
email_from = author.email_formatted
# superuser mode without author email -> probably public user; anyway we don't want to crash
# if not email_from and raise_on_email and not self.env.su:
# raise exceptions.UserError(_("Unable to send message, please configure the sender's email address."))
return author_id, email_from
......@@ -7,9 +7,9 @@
<field name="model">cc.node.exception.reason</field>
<field name="arch" type="xml">
<tree string="CC Node Exception Reason" editable="bottom">
<field optional="show" name="code_id" string="Node" options="{'no_create':True}"/>
<field optional="show" name="name" string="Node Name"/>
<field optional="show" name="desc" string="Node Description"/>
<field optional="show" name="code_id" options="{'no_create':True}"/>
<field optional="show" name="name"/>
<field optional="show" name="desc"/>
</tree>
</field>
</record>
......@@ -21,8 +21,8 @@
<field name="arch" type="xml">
<search string="Search Node">
<field name="code_id"/>
<field name="name" string="Node Name"/>
<field name="desc" string="Node Description"/>
<field name="name"/>
<field name="desc"/>
<group expand="0" string="Group By">
<filter string="Node" name="group_code_id" context="{'group_by':'code_id'}"/>
</group>
......
......@@ -81,7 +81,7 @@ class BatchInputShipPackageStatusWizard(models.TransientModel):
{'state': self.update_status.id, 'node_exception_reason_id': self.node_exception_reason_id.id,
'process_time': self.process_time, 'state_explain': self.state_explain, 'is_sync': False})
# 生成sns日志
self.bl_id.message_post(body='%s更新为%s' % (self.current_status.name or '', self.update_status.name or ''))
# self.bl_id.message_post(body='%s更新为%s' % (self.current_status.name or '', self.update_status.name or ''))
# 跳转显示本次更新状态的小包
return {
'name': '更新小包状态',
......
......@@ -26,7 +26,7 @@
<separator/>
<!-- domain="[('id','in',next_code_ids),('node_type','=','package')]"-->
<field name="update_status" required="1"/>
<field name="process_time" required="1" string="Process Time(UTC)"/>
<field name="process_time" required="1" string="Process Time"/>
<field name="node_exception_reason_id" options="{'no_create':True}"/>
<field name="state_explain"/>
</group>
......
......@@ -17,7 +17,7 @@
# data
# 'data/data.xml',
# wizard
# 'wizard/push_result.xml',
'wizard/batch_input_ship_package_statu_wizard.xml',
# 'wizard/again_push_wizard.xml',
# 'wizard/batch_push_tiktok.xml',
# view
......
# -*- coding: utf-8 -*-
# from . import push_result
# from . import again_push_wizard
# from . import parcel_exception_wizard
# from . import big_bag_pickup_wizard
# from . import batch_push_tiktok
# from . import big_bag_check_wizard
from . import batch_input_ship_package_statu_wizard
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, api, fields
from odoo.exceptions import Warning, ValidationError
# 定义一个批量更新小包状态的向导, 用于批量更新小包状态
# 包括以下字段,提单, 当前节点, 更新节点, 排除面单号, 排除状态
class BatchInputShipPackageStatusWizard(models.TransientModel):
_inherit = 'batch.input.ship.package.status.wizard'
_description = '批量更新小包状态向导'
@api.depends('select_type', 'update_status', 'current_status')
def cal_ship_package_ids(self):
"""
比如 已提货 --- 清关开始,选择了清关开始之后 把已提货状态的小包且更新日志明细包含了 清关开始 的编码的 小包显示出来
"""
for item in self:
package_ids = []
package_obj = False
package_model = self.env['cc.ship.package']
if item.select_type == 'tracking_no':
if item.select_tracking_no:
tracking_no_list = item.select_tracking_no.split(',')
tracking_no_list = [i.strip() for i in tracking_no_list if i.strip()]
package_obj = package_model.search(
[('bl_id', '=', item.bl_id.id), ('tracking_no', 'in', tracking_no_list)])
else:
# 获取所有的小包
if item.current_status:
package_obj = package_model.search(
[('bl_id', '=', item.bl_id.id), ('state', '=', item.current_status.id)])
if package_obj:
# 更新日志明细包含了 清关开始 的 小包
log_obj = self.env['cc.ship.package.sync.log'].search(
[('package_id', 'in', package_obj.ids), ('process_code', '=', item.update_status.tk_code)])
package_ids = log_obj.mapped('package_id').ids
item.ship_package_ids = [(6, 0, package_ids)]
ship_package_ids = fields.Many2many('cc.ship.package', '_update_state_package_wizard_rel', 'wizard_id',
'package_id', 'Have Node Package', compute='cal_ship_package_ids')
def submit(self):
obj = super(BatchInputShipPackageStatusWizard, self).submit()
# 生成sns日志
self.bl_id.message_post(body='[%s]%s更新为[%s]%s' % (
self.current_status.tk_code or '', self.current_status.name or '', self.update_status.tk_code or '',
self.update_status.name or ''))
# 跳转显示本次更新状态的小包
return obj
<?xml version="1.0" encoding="utf-8"?>
<!-- © <2016> <heyang>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<data>
<record id="view_batch_input_ship_package_wizard" model="ir.ui.view">
<field name="name">更新包裹进度</field>
<field name="model">batch.input.ship.package.status.wizard</field>
<field name="inherit_id" ref="ccs_base.view_batch_input_ship_package_wizard"/>
<field name="arch" type="xml">
<field name="update_status" position="after">
<field name="ship_package_ids" widget="one2many" readonly="1">
<tree>
<field name="logistic_order_no"/>
<field name="tracking_no"/>
<field name="state"/>
</tree>
</field>
</field>
</field>
</record>
</data>
</odoo>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论