diff --git a/appstore/Yc_Demo/__init__.py b/appstore/Yc_Demo/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..a0fdc10fe11b9eb562881952079e34c2982f8604 --- /dev/null +++ b/appstore/Yc_Demo/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import models diff --git a/appstore/Yc_Demo/__manifest__.py b/appstore/Yc_Demo/__manifest__.py new file mode 100644 index 0000000000000000000000000000000000000000..af297cfcb62e8e0284f689a8135e29c039f888a1 --- /dev/null +++ b/appstore/Yc_Demo/__manifest__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +# AmosERP dtcloud11.0 +# QQ:35350428 +# 邮件:35350428@qq.com +# 手机:13584935775 +# 作者:'amos' +# 公司网址: www.dtcloud.pw www.100china.cn www.amoserp.com +# Copyright 昆山一百计算机有限公司 2012-2020 Amos +# 日期:2020/2/13 +# &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& + +{ + 'name': '我的测试', + 'summary': '测试', + 'category': u'YanChun/测试', + 'sequence': 10001, + 'author': 'Amos', + 'depends': ['base', 'mail', 'documents', 'sale'], + 'version': '0.1', + 'data': [ + 'data/mail_data.xml', + 'views/product_inherit.xml', + ], + 'installable': True, + 'application': True, + 'auto_install': False, + 'description': """默认提供静态参数""", +} diff --git a/appstore/Yc_Demo/data/mail_data.xml b/appstore/Yc_Demo/data/mail_data.xml new file mode 100644 index 0000000000000000000000000000000000000000..7aec51385e4f215495a7a31f9f8d2dbb68c9a764 --- /dev/null +++ b/appstore/Yc_Demo/data/mail_data.xml @@ -0,0 +1,63 @@ + + + + + 销售订单: 发送邮件 + + ${object.name or 'n/a' } + + ${(object.user_id.email_formatted or user.email_formatted) | safe} + ${object.partner_id.id} + +
+ 尊敬的${object.partner_id.name},您好! +
+ 您的本期消费概览情况如下: +
+

订单编号:${object.name}

+ + + + + + + + + + + % for line in object.order_line: + + + + + + + % endfor + + + + + +
产品数量单价小计
${ line.product_id.name }${ line.product_uom_qty }${format_amount(object.price_unit, object.currency_id)}${format_amount(object.price_subtotal, object.currency_id)}
合计:${format_amount(object.amount_total, object.currency_id)}
+

下载链接: + ${ctx.get('full_url')} +

+

温馨提示:

+ 该链接有效期至 + ${ctx.get('date_deadline')} +
+ 请尽快完成下载! +
+
+
+ 此致 +

中亿丰数字科技有限公司

+
+
+ + ${(object.name or '').replace('/','_')} + ${object.partner_id.lang} + +
+
+
diff --git a/appstore/Yc_Demo/models/__init__.py b/appstore/Yc_Demo/models/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..7675c9fee611ef5ed55e1c27c50d1d4b45a06aa7 --- /dev/null +++ b/appstore/Yc_Demo/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +from . import product_inherit +from . import sale_order_inherit \ No newline at end of file diff --git a/appstore/Yc_Demo/models/product_inherit.py b/appstore/Yc_Demo/models/product_inherit.py new file mode 100644 index 0000000000000000000000000000000000000000..a5ccee1439a97374a78dc53dccebde5906d7913d --- /dev/null +++ b/appstore/Yc_Demo/models/product_inherit.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +from dtcloud import api, fields, models, tools + + +### 扩展产品文档 +class ProductInherit(models.Model): + _inherit = 'product.product' + + document_id = fields.Many2one('documents.document', string='文档', required=True, ondelete='cascade', index=True, + copy=False) + + + + diff --git a/appstore/Yc_Demo/models/sale_order_inherit.py b/appstore/Yc_Demo/models/sale_order_inherit.py new file mode 100644 index 0000000000000000000000000000000000000000..d0dadc4329cc6b69264a34cae7e9d950f584814a --- /dev/null +++ b/appstore/Yc_Demo/models/sale_order_inherit.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +from datetime import timedelta + +from dtcloud import api, fields, models, tools + + +### 扩展销售订单 +class SaleOrderInherit(models.Model): + _inherit = 'sale.order' + + ### 重写销售订单发送邮件方法 + def action_quotation_send(self): + ''' Opens a wizard to compose an email, with relevant mail template loaded by default ''' + self.ensure_one() + # 获取销售订单明细列表 + document_ids = self.order_line.product_id.document_id + # 在这里修改模版值 + template_id = self.env.ref('Yc_Demo.yc_demo_email_template_edi_sale3').id + lang = self.env.context.get('lang') + template = self.env['mail.template'].browse(template_id) + if template.lang: + lang = template._render_lang(self.ids)[self.id] + ctx = { + 'default_model': self._name, + 'default_res_id': self.ids[0], + 'default_use_template': bool(template_id), + 'default_template_id': template_id, + 'default_composition_mode': 'comment', + 'mark_so_as_sent': True, + 'custom_layout': "mail.mail_notification_paynow", + 'proforma': self.env.context.get('proforma', False), + 'force_email': True, + 'model_description': self.with_context(lang=lang).type_name, + } + if document_ids.ids: + # 创建URL分享链接 + vals = { + 'type': 'ids', + 'document_ids': [(6, 0, document_ids.ids)], + 'folder_id': document_ids[0].folder_id.id, + } + # 有效时长 + week = 7 + date_deadline = fields.Datetime.to_string(fields.datetime.now() + timedelta(days=week)) + vals.update({ + "date_deadline": date_deadline, + "type": "ids", # 分享类别 + 'activity_date_deadline_range': week, + 'activity_date_deadline_range_type': "days", + 'state': "live", + }) + + documents_share_id = self.env['documents.share'].create(vals) + # 路径 full_url + full_url = documents_share_id.full_url + # 向Email中填充下载地址 + template.body_html = full_url + ctx.update({ + "full_url": full_url, + "date_deadline": date_deadline + }) + + return { + 'type': 'ir.actions.act_window', + 'view_mode': 'form', + 'res_model': 'mail.compose.message', + 'views': [(False, 'form')], + 'view_id': False, + 'target': 'new', + 'context': ctx, + } diff --git a/appstore/Yc_Demo/security/ir.model.access.csv b/appstore/Yc_Demo/security/ir.model.access.csv new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/appstore/Yc_Demo/views/product_inherit.xml b/appstore/Yc_Demo/views/product_inherit.xml new file mode 100644 index 0000000000000000000000000000000000000000..db03e2a5b4434c40a1786ebcdc740fc65ccf72d6 --- /dev/null +++ b/appstore/Yc_Demo/views/product_inherit.xml @@ -0,0 +1,15 @@ + + + + + 产品变体form + product.product + + + + + + + + + \ No newline at end of file