提交 2705567e authored 作者: 贺阳's avatar 贺阳

大包 创建旁边增加关联托盘按钮

上级 e41599c4
......@@ -45,7 +45,12 @@
# 'post_init_hook': '_account_post_init',
'assets': {
'web.assets_frontend': [
'ccs_base/static/css/base.scss',
'ccs_base/static/src/css/base.scss',
],
'web.assets_backend': [
'ccs_base/static/src/mixins/*.js',
'ccs_base/static/src/views/*.js',
'ccs_base/static/src/views/*.xml',
],
},
'license': 'AGPL-3',
......
......@@ -64,6 +64,8 @@ class CcBigPackage(models.Model):
], default='unprocessed_goods', string='Tally Status', index=True) # 理货状态 未理货/已理货/尾程交接
tally_user_id = fields.Many2one('res.users', 'Tally User', index=True) # 理货人
tally_time = fields.Datetime('Tally Time') # 理货时间
exception_info_ids = fields.Many2many('cc.exception.info', 'bigpackage_exception_info_rel',
string='Exception Information')
# 创建显示包裹的action
def action_show_ship_package(self):
......@@ -100,6 +102,32 @@ class CcBigPackage(models.Model):
'context': {'active_id': self.id}
}
def action_cc_big_package(self):
"""
菜单 大包
:return:
"""
return {
"name": self._description,
"type": "ir.actions.act_window",
"res_model": self._name,
'view_mode': 'tree,form,pivot,graph',
"context": {'is_show': self.env.user.has_group('ccs_base.group_clearance_of_customs_manager')}
}
def action_package_exception_info(self):
"""
点击添加异常原因,弹出向导
"""
return {
'name': _('Add Package Exception Information'),
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'add.exception.info.wizard',
'target': 'new',
'context': {'active_id': self.id, 'default_action_type': 'big package'}
}
# 创建一个商品的业务对象,用来管理包裹的商品信息.商品信息包括所属包裹、SKU标识ID、商品中文名称、商品英文名称、出口HSCode,进口HSCode,重量、数量,数量单位,申报单价,运费, COD金额, VAT税率, 商品VAT,原产国, 类型:赠品,商品总价,商品链接,商品交税情况(包含:TTSTaxed: 已税
# Sentinel: 未税
......@@ -407,6 +435,19 @@ class CcShipPackage(models.Model):
'domain': [('bl_line_id', '=', self.id), ('is_cancel', '=', False)],
}
def action_package_exception_info(self):
"""
点击添加异常原因,弹出向导
"""
return {
'name': _('Add Package Exception Information'),
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'add.exception.info.wizard',
'target': 'new',
'context': {'active_id': self.id, 'default_action_type': 'ship package'}
}
# 翻译
# def action_bl_line_translate(self):
# # http代理:proxies={'http': 'http://localhost:10809', 'https': 'http://localhost:10809'}
......
......@@ -4,7 +4,7 @@ from odoo import models, fields, api
class CCExceptionInfo(models.Model):
_name = 'cc.exception.info'
_description = 'Exception Information'
_description = 'Package Exception Information'
_rec_name = 'reason'
@api.model
......
odoo.define('ccs_base.order_link_pallet', function (require) {
"use strict";
var ListController = require('web.ListController');
ListController.include({
renderButtons: function ($node) {
this._super.apply(this, arguments);
if (this.$buttons) {
this.$buttons.on('click', '.o_list_order_link_pallet', this.order_link_pallet.bind(this));
}
},
order_link_pallet: function () {
var self = this;
self.do_action({
type: 'ir.actions.act_window',
name: _('Link Pallet'),
target: 'new',
res_model: 'associate.pallet.wizard',
views: [[false, 'form']],
context: {},
});
}
});
});
/** @odoo-module */
import {useService} from '@web/core/utils/hooks';
const {useRef, useEffect, useState} = owl;
export const BigPackageLinkPallet = {
setup() {
this._super();
this.actionService = useService('action');
this.notification = useService('notification');
this.orm = useService('orm');
this.http = useService('http');
this.fileInput = useRef('fileInput');
this.root = useRef("root");
this.isBigPackage = this.model.rootParams.resModel === "cc.big.package";
this.is_link = this.user.hasGroup("ccs_base.group_clearance_of_customs_manager");
},
displayLink() {
// 是大包的对象以及有清关清理的权限才显示按钮
return this.isBigPackage && this.is_link;
},
async onLinkPalletClick() {
// 点击按钮弹出关联托盘的向导
await this.actionService.doAction({
'name': _('Link Pallet'),
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'associate.pallet.wizard',
'target': 'new',
});
console.log('111111111')
// const action = await this.orm.call('cc.big.package', 'action_link_pallet', [""]);
// console.log('action:'+action)
// this.actionService.doAction(action);
},
};
/** @odoo-module */
import { BigPackageLinkPallet } from '../mixins/link_pallet';
import { registry } from '@web/core/registry';
import { patch } from '@web/core/utils/patch';
import { useService } from '@web/core/utils/hooks';
import { listView } from "@web/views/list/list_view";
import { ListController } from "@web/views/list/list_controller";
import { ListRenderer } from "@web/views/list/list_renderer";
const { onWillStart } = owl;
export class BigPackageListController extends ListController {
setup() {
super.setup();
console.log('----------引用成功')
this.orm = useService('orm');
this.actionService = useService('action');
this.rpc = useService("rpc");
this.user = useService("user");
}
}
patch(BigPackageListController.prototype, 'big_package_list_controller_link_pallet', BigPackageLinkPallet);
registry.category('views').add('cc_big_package_tree', {
...listView,
buttonTemplate: 'ccs_base.ListButtons',
Controller: BigPackageListController
});
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="ccs_base.ListButtons" t-inherit="web.ListView.Buttons" t-inherit-mode="primary" owl="1">
<xpath expr="//button[hasclass('o_list_button_add')]" position="after">
<button t-if="displayLink()" type="button" class="d-none d-md-inline o_button_link_pallet btn btn-primary mx-1" t-on-click.prevent="onLinkPalletClick">
Link Pallet
</button>
</xpath>
</t>
</templates>
......@@ -6,7 +6,7 @@
<field name="name">tree.cc.big.package</field>
<field name="model">cc.big.package</field>
<field name="arch" type="xml">
<tree string="Big Package" decoration-warning="is_cancel==True">
<tree string="Big Package" js_class="cc_big_package_tree" decoration-warning="is_cancel==True">
<field optional="show" name="big_package_no" string="Big Package No."/>
<field optional="show" name="bl_id" string="Bill of Loading"/>
<field name="ship_package_qty" string="Packages Qty"/>
......@@ -55,6 +55,7 @@
<field name="big_package_no" string="Big Package No."/>
<field name="bl_id" string="Bill of Loading"/>
<field name="next_provider_name" string="Next Provider Name"/>
<field name="exception_info_ids" widget="many2many_tags"/>
<field name="is_cancel" string="Cancelled"/>
<field name="tally_state" readonly="1"/>
<field name="tally_user_id" readonly="1" options="{'no_create':True}"/>
......@@ -112,6 +113,18 @@
</field>
</record>
<menuitem parent="" sequence="13" name="Big Package" id="menu_cc_big_package" action="action_cc_big_package"/>
<menuitem parent="" sequence="13" name="Big Package" id="menu_cc_big_package" action="action_cc_big_package"/>
<!-- <record id="action_cc_big_package_server" model="ir.actions.server">-->
<!-- <field name="name">全部航班</field>-->
<!-- <field name="model_id" ref="model_cc_big_package"/>-->
<!-- <field name="state">code</field>-->
<!-- <field name="code">-->
<!-- action = model.action_cc_big_package()-->
<!-- </field>-->
<!-- </record>-->
<!-- <menuitem id="menu_cc_big_package" name="Big Package" action="action_cc_big_package_server" sequence="13"/>-->
</odoo>
\ No newline at end of file
......@@ -3,7 +3,7 @@
<field name="name">exception.info.form</field>
<field name="model">cc.exception.info</field>
<field name="arch" type="xml">
<form string="Exception Information">
<form string="Package Exception Information">
<sheet>
<group>
<field name="exception_code" readonly="1"/> <!-- 异常编码 -->
......@@ -19,7 +19,7 @@
<field name="name">exception.info.tree</field>
<field name="model">cc.exception.info</field>
<field name="arch" type="xml">
<tree string="Exception Information">
<tree string="Package Exception Information">
<field name="exception_code"/> <!-- 异常编码 -->
<field name="reason"/> <!-- 异常原因 -->
<field name="responsible_email"/> <!-- 异常接收负责人邮箱 -->
......@@ -31,7 +31,7 @@
<field name="name">exception.info.search</field>
<field name="model">cc.exception.info</field>
<field name="arch" type="xml">
<search string="Exception Information">
<search string="Package Exception Information">
<field name="exception_code"/>
<field name="reason"/>
</search>
......@@ -39,11 +39,11 @@
</record>
<record id="action_exception_info" model="ir.actions.act_window">
<field name="name">Exception Information</field>
<field name="name">Package Exception Information</field>
<field name="res_model">cc.exception.info</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="menu_exception_info" name="Exception Information" parent="menu_ccs_base_main" sequence="98"
<menuitem id="menu_exception_info" name="Package Exception Information" parent="menu_ccs_base_main" sequence="98"
action="action_exception_info"/>
</odoo>
\ No newline at end of file
......@@ -12,6 +12,7 @@
<field optional="show" name="name" string="Node Name"/>
<field optional="show" name="desc" string="Node Description"/>
<field optional="show" name="next_code_ids" widget="many2many_tags" options="{'no_create':True}"/>
<field optional="show" name="tally_state"/>
<field optional="show" name="is_must" string="Is Must Node"/>
<field optional="show" name="is_done" string="Is Done Node"/>
<field optional="show" name="is_default" string="Is Current Node"/>
......
......@@ -79,6 +79,10 @@
<field name="arch" type="xml">
<form string="Ship Package">
<header>
<button name="action_package_exception_info" type="object"
string="Add Package Exception Information"
groups="ccs_base.group_clearance_of_customs_manager"/><!-- 关联托盘 -->
<field name="state" string="Progress Status" widget="statusbar"/>
</header>
<sheet>
......@@ -94,6 +98,7 @@
<field name="big_package_id" string="Big Package"/>
<field name="bl_id" string="Bill of Loading"/>
<field name="next_provider_name" string="Next Provider Name"/>
<field name="exception_info_ids" widget="many2many_tags"/>
<field name="process_time" readonly="1"/>
</group>
......
......@@ -4,8 +4,15 @@ from odoo.exceptions import UserError
class AddExceptionInfoWizard(models.TransientModel):
_name = 'add.exception.info.wizard'
_description = 'Add Exception Information Wizard'
_description = 'Add Package Exception Information Wizard'
def get_order(self):
order_id = self._context.get('active_id')
if type(order_id) != list:
order_id = [self._context.get('active_id')]
return self.env[self._context.get('active_name')].browse(order_id)
action_type = fields.Char(string='Action Type', hemp='ship package/big package')
exception_ids = fields.Many2many('exception.info', 'big_package_add_exception_rel', string='Exception Information',
required=True) # 异常信息(多选)
send_email = fields.Boolean(string='Send Email Notification', default=False) # 发送邮件通知
......@@ -18,28 +25,29 @@ class AddExceptionInfoWizard(models.TransientModel):
def confirm(self):
for record in self:
# 更新小包的异常信息
exception_objs=record.exception_ids
package_objs = self.env['big.package'].search([('id', 'in', self.env.context.get('active_id'))])
for package in package_objs:
package.exception_info_ids = [(6,0,exception_objs.ids)] # 回写小包的异常信息
exception_objs = record.exception_ids
package_objs = self.get_order()
for package in package_objs:
package.exception_info_ids = [(6, 0, exception_objs.ids)] # 回写小包的异常信息
# 发送邮件通知
if record.send_email:
self.send_email_notification(package)
def send_email_notification(self, package,exception_objs):
def send_email_notification(self, package, exception_objs):
"""
发送对应语言的邮件 '/'.join([exception.reason for exception in exception_objs])
"""
if self.email_language == 'zh':
template_id = self.env.ref('your_module.email_template_exception_notification')
else:
template_id = self.env.ref('your_module.email_template_exception_notification_en') # Assuming you have an English template
template_id = self.env.ref(
'your_module.email_template_exception_notification_en') # Assuming you have an English template
if template_id:
template_id.send_mail(package.id, force_send=True,
email_values={
'email_to': '',
'email_from': ''
})
email_values={
'email_to': '',
'email_from': ''
})
else:
raise UserError("Email template not found.")
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论