diff --git a/extra-addons/kci-contact/views/custom_partner_views.xml b/extra-addons/kci-contact/views/custom_partner_views.xml index 5a02905a3c83bc7a320af88c947b2b2aab0737ad..379fb6579f6cce38f654c0a912d7ba2258172956 100644 --- a/extra-addons/kci-contact/views/custom_partner_views.xml +++ b/extra-addons/kci-contact/views/custom_partner_views.xml @@ -6,25 +6,40 @@ <field name="inherit_id" ref="base.view_partner_form"/> <field name="arch" type="xml"> - <xpath expr="//sheet/group/group/field[@name='function']" position="before"> - <field name="custom"/> + <xpath expr="//sheet/group/group/div[@class='o_address_format']" position="replace"> + <field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}' + attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/> + <field name="city" placeholder="City" class="o_address_city" + attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/> + <field name="state_id" class="o_address_state" placeholder="State" options="{'no_open': True, 'no_quick_create': True}" + attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}" context="{'country_id': country_id, 'default_country_id': country_id, 'zip': zip}"/> + <field name="zip" placeholder="ZIP" class="o_address_zip" + attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/> + <field name="street" placeholder="Street..." class="o_address_street" + attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/> + <field name="street2" placeholder="Street 2..." class="o_address_street" + attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/> </xpath> - <xpath expr="//sheet/group/group/field[@name='custom']" position="after"> - <field name="supply"/> + <xpath expr="//sheet/group/group/field[@name='vat']" position="after"> + <field name="factory"/> + <field name="department"/> </xpath> - <xpath expr="//sheet/group/group/field[@name='supply']" position="after"> + <xpath expr="//sheet/group/group/field[@name='function']" position="before"> + <field name="custom"/> + <field name="supply"/> <field name="employee"/> + <field name="contact_code"/> </xpath> - <xpath expr="//sheet/group/group/field[@name='employee']" position="after"> - <field name="contact_code"/> + <xpath expr="//sheet/group/group/field[@name='website']" position="replace"> + <field name="website" string="Website" widget="url" placeholder="e.g. https://www.odoo.com" invisible="1"/> </xpath> - <xpath expr="//sheet/group/group/field[@name='vat']" position="after"> - <field name="factory"/> - <field name="department"/> + <xpath expr="//sheet/group/group/field[@name='title']" position="replace"> + <field name="title" options='{"no_open": True}' placeholder="e.g. Mister" + attrs="{'invisible': [('is_company', '=', True)]}" string="蝔梯�"/> </xpath> </field> diff --git a/extra-addons/kci-mrp/__manifest__.py b/extra-addons/kci-mrp/__manifest__.py index a09a61fd53eb328039057f0a81b3beaeb0e56c2a..cb03dcbc47400fa1c600caaf77cc599753a6780b 100644 --- a/extra-addons/kci-mrp/__manifest__.py +++ b/extra-addons/kci-mrp/__manifest__.py @@ -20,6 +20,7 @@ This module contains all the common features of Drawings. 'views/mrp_views_menu.xml', 'views/mrp_groups.xml', 'report/bom_for_sales.xml', + 'data/bom_email.xml', ], 'application': True, 'installable': True, diff --git a/extra-addons/kci-mrp/data/bom_email.xml b/extra-addons/kci-mrp/data/bom_email.xml new file mode 100644 index 0000000000000000000000000000000000000000..61ab110c3525b6dc54c8b2fd2d80837c2945c444 --- /dev/null +++ b/extra-addons/kci-mrp/data/bom_email.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <data noupdate="1"> + <record id="bom_email_template" model="mail.template"> + <field name="name">BOM Email Template</field> + <field name="email_from">erp_system@kci-global.com.tw</field> + <field name="subject">[KCI ERP System] BOM �𡁶䰻</field> + <field name="model_id" ref="mrp.model_mrp_bom"/> + <field name="auto_delete" eval="False"/> + <field name="body_html" type="html"> + <div>test</div> + </field> + </record> + </data> +</odoo> diff --git a/extra-addons/kci-mrp/models/mrp_bom.py b/extra-addons/kci-mrp/models/mrp_bom.py index a7e04e2bce20658b5b5bd95595832846fe696746..a23dc086bbda97338c52ab7a27f11e07ef4872e0 100644 --- a/extra-addons/kci-mrp/models/mrp_bom.py +++ b/extra-addons/kci-mrp/models/mrp_bom.py @@ -4,7 +4,7 @@ from odoo import api, fields, models class Bom(models.Model): - _inherit = ["mrp.bom"] + _inherit = "mrp.bom" status = fields.Selection([ ('internal', 'bom1'), @@ -71,7 +71,7 @@ class Bom(models.Model): 'res_partner_id': self.env.user.partner_id.id, 'notification_type': 'inbox'}))] user_id = self.env.user.id - message = f"撌脣遣蝡见𥼚�孵鱓 <a href='{url}'>{quotation_name}</a> " + message = f"撌脣遣蝡见𥼚�孵鱓 <a href='{self.env['ir.config_parameter'].sudo().get_param('web.base.url')}{url}'>{quotation_name}</a> " target_user = self.env['res.partner'].browse(target_partner_id) target_user.message_post(author_id=user_id, body=message + "隢𧢲䰻�𤣰", @@ -82,13 +82,22 @@ class Bom(models.Model): notify_by_email=False, ) self.send_notification_to_self(message) + email_values = { + 'email_to': target_user, + 'email_cc': self.env.user.partner_id.email, + 'email_from': "erp_system@kci-global.com.tw", + 'subject': '[KCI ERP System] �𥼚�孵鱓�𡁶䰻', + 'body_html': message, + } + mail_template = self.env.ref('kci-mrp.bom_email_template') + mail_template.send_mail(self.id, force_send=True, email_values=email_values) def action_send_bom_notification(self, bom_name, is_create, url): notification_ids = [((0, 0, { 'res_partner_id': self.env.user.partner_id.id, 'notification_type': 'inbox'}))] user_id = self.env.user.id - message = f"撌現'撱箇��' if is_create else '�凒�鰵'} BOM <a href='{url}'>{bom_name}</a> " + message = f"撌現'撱箇��' if is_create else '�凒�鰵'} BOM <a href='{self.env['ir.config_parameter'].sudo().get_param('web.base.url')}{url}'>{bom_name}</a> " group = self.env['mail.channel'].search([('group_public_id', '=', self.env.ref('sales.kci_sales_manager_group' if is_create else 'kci-mrp.kci_mrp_manager_group').id)]) group.message_post(author_id=user_id, body=message + "隢𧢲䰻�𤣰", @@ -99,6 +108,17 @@ class Bom(models.Model): notify_by_email=False, ) self.send_notification_to_self(message) + email_to = '' + for partner in group.channel_partner_ids: + email_to += f'{partner.email}, ' + email_values = { + 'email_to': email_to, + 'email_cc': self.env.user.partner_id.email, + 'email_from': "erp_system@kci-global.com.tw", + 'body_html': message, + } + mail_template = self.env.ref('kci-mrp.bom_email_template') + mail_template.send_mail(self.id, force_send=True, email_values=email_values) @api.depends('bom_line_ids.price') def _compute_total(self): diff --git a/extra-addons/kci-mrp/models/mrp_drawing.py b/extra-addons/kci-mrp/models/mrp_drawing.py index d1460db837fe9ec153434e978537298105c1b851..59c17a1da2ca0174db0b2848a1d0cb71c8143241 100644 --- a/extra-addons/kci-mrp/models/mrp_drawing.py +++ b/extra-addons/kci-mrp/models/mrp_drawing.py @@ -13,13 +13,13 @@ class MrpDrawing(models.Model): # _order = "sequence, id" # _check_company_auto = True - code = fields.Char('Reference', tracking=True) - name = fields.Char(size=100, tracking=True) - version = fields.Char(size=100, tracking=True) - description = fields.Char(size=1000, tracking=True) + code = fields.Char(string='蝺刻��', tracking=True) + name = fields.Char(string='��滨迂', size=100, tracking=True) + version = fields.Char(string='���𧋦', size=100, tracking=True) + description = fields.Char(string='隤芣��', size=1000, tracking=True) material_id = fields.Many2one('mrp.drawing.material', string='��鞱釭') product_id = fields.Many2one( - 'product.product', 'Component', + 'product.product', string='��嗘辣', check_company=False, index=True, required=True) product_tmpl_id = fields.Many2one( 'product.template', 'Product Template', related='product_id.product_tmpl_id', @@ -30,8 +30,8 @@ class MrpDrawing(models.Model): drawing_line_ids = fields.One2many('mrp.drawing.line', 'drawing_id', 'Drawing Lines', copy=True, tracking=True) - upload_date = fields.Datetime('Upload Date', default=fields.Datetime.now, readonly=True) - last_update_date = fields.Datetime('Update Date', default=fields.Datetime.now, readonly=False) + upload_date = fields.Datetime(string='銝𠰴�單����', default=fields.Datetime.now, readonly=True) + last_update_date = fields.Datetime(string='��敺峕凒�鰵�����', default=fields.Datetime.now, readonly=False) @api.onchange('code', 'name', 'version', 'description', 'product_id', 'product_tmpl_id', 'company_id', 'drawing_line_ids') def _refresh_update_date(self): @@ -50,13 +50,13 @@ class MrpDrawingLine(models.Model): 'res.company', 'Company', index=True, default=lambda self: self.env.company) - name = fields.Char(size=100) - description = fields.Char(size=1000) + name = fields.Char(size=100, string='��滨迂') + description = fields.Char(size=1000, string='隤芣��') drawing_id = fields.Many2one('mrp.drawing', 'Parent Drawing', index=True, ondelete='cascade', required=True, default=False) - drawing_file = fields.Binary('File', tracking=True) + drawing_file = fields.Binary(string='瑼娍��', tracking=True) drawing_file_name = fields.Char('File Name') - upload_date = fields.Datetime('Upload Date', default=fields.Datetime.now, readonly=True) + upload_date = fields.Datetime(string='銝𠰴�單����', default=fields.Datetime.now, readonly=True) # @api.model # def create(self, vals): diff --git a/extra-addons/kci-mrp/security/ir.model.access.csv b/extra-addons/kci-mrp/security/ir.model.access.csv index 5cbceb8e21557a99c450d89c708221b3870fdddb..c9791fcc4a01a5c96a36d0bcc0a9179b06b86986 100644 --- a/extra-addons/kci-mrp/security/ir.model.access.csv +++ b/extra-addons/kci-mrp/security/ir.model.access.csv @@ -1,3 +1,7 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_mrp_drawing_user,MRP Drawing User Access,model_mrp_drawing,mrp_drawing_group_user,1,0,0,0 -access_mrp_drawing_manager,MRP Drawing Manager Access,model_mrp_drawing,mrp_drawing_group_manager,1,1,1,1 \ No newline at end of file +access_mrp_drawing_manager,MRP Drawing Manager Access,model_mrp_drawing,mrp_drawing_group_manager,1,1,1,1 +access_mrp_drawing_line_user,MRP Drawing Line User Access,model_mrp_drawing_line,mrp_drawing_group_user,1,0,0,0 +access_mrp_drawing_line_manager,MRP Drawing Line Manager Access,model_mrp_drawing_line,mrp_drawing_group_manager,1,1,1,1 +access_mrp_drawing_material_user,MRP Drawing Material User Access,model_mrp_drawing_material,mrp_drawing_group_user,1,0,0,0 +access_mrp_drawing_material_manager,MRP Drawing Material Manager Access,model_mrp_drawing_material,mrp_drawing_group_manager,1,1,1,1 \ No newline at end of file diff --git a/extra-addons/kci-mrp/views/mrp_drawing_views.xml b/extra-addons/kci-mrp/views/mrp_drawing_views.xml index 0f8d3983e1db7963f3bf316ade799bf65af7a1c9..4532e09e2e93de8d468dd6eb7a263ffaf1a3dae6 100644 --- a/extra-addons/kci-mrp/views/mrp_drawing_views.xml +++ b/extra-addons/kci-mrp/views/mrp_drawing_views.xml @@ -23,7 +23,7 @@ </group> </group> <notebook> - <page string="Drawings" name="drawings"> + <page string="��㚚𢒰瑼娍��" name="drawings"> <field name="drawing_line_ids" widget="one2many"> <tree string="Drawings" editable="bottom"> <field name="company_id" invisible="1"/> diff --git a/extra-addons/kci-project/__manifest__.py b/extra-addons/kci-project/__manifest__.py index 99527c9d0216d7ef4aab96cc1e8ddec46627689f..26ab38139d34baa2258cd3612ac6bc9e50e2ac08 100644 --- a/extra-addons/kci-project/__manifest__.py +++ b/extra-addons/kci-project/__manifest__.py @@ -11,7 +11,12 @@ This module contains all the common features of project. """, 'depends': ['project', 'purchase', 'sale', 'mrp'], 'data': [ + 'security/security.xml', + 'security/ir.model.access.csv', 'views/project_views.xml', + 'data/cron_deadline_check.xml', + 'data/cron_deadline_notification_check.xml', + 'data/cron_deadline_notification_email.xml', ], 'application': True, 'installable': True, diff --git a/extra-addons/kci-project/data/cron_deadline_check.xml b/extra-addons/kci-project/data/cron_deadline_check.xml new file mode 100644 index 0000000000000000000000000000000000000000..11851d1a4569f8df52c6068e4fbddaeb534d08a6 --- /dev/null +++ b/extra-addons/kci-project/data/cron_deadline_check.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<odoo> + <data noupdate="1"> + <record id="deadline_check_cron" model="ir.cron"> + <field name="name">Task Deadline Check Cron</field> + <field name="model_id" ref="model_project_task"/> + <field name="state">code</field> + <field name="code">model.cron_deadline_check()</field> + <field name="user_id" ref="base.user_root"/> + <field name='interval_number'>1</field> + <field name='interval_type'>minutes</field> + <field name="numbercall">-1</field> + <field name="doall" eval="False"/> + </record> + </data> +</odoo> \ No newline at end of file diff --git a/extra-addons/kci-project/data/cron_deadline_notification_check.xml b/extra-addons/kci-project/data/cron_deadline_notification_check.xml new file mode 100644 index 0000000000000000000000000000000000000000..323ad1670c4e0630868959665504c777e16b270b --- /dev/null +++ b/extra-addons/kci-project/data/cron_deadline_notification_check.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<odoo> + <data noupdate="1"> + <record id="deadline_notification_check_cron" model="ir.cron"> + <field name="name">Task Deadline Notification Check Cron</field> + <field name="model_id" ref="model_project_task"/> + <field name="state">code</field> + <field name="code">model.cron_deadline_notification_check()</field> + <field name="user_id" ref="base.user_root"/> + <field name='interval_number'>1</field> + <field name='interval_type'>days</field> + <field name="numbercall">-1</field> + <field name="doall" eval="False"/> + </record> + </data> +</odoo> \ No newline at end of file diff --git a/extra-addons/kci-project/data/cron_deadline_notification_email.xml b/extra-addons/kci-project/data/cron_deadline_notification_email.xml new file mode 100644 index 0000000000000000000000000000000000000000..81e59944bbed0ccc301284a11867841fafe3ec20 --- /dev/null +++ b/extra-addons/kci-project/data/cron_deadline_notification_email.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <data noupdate="1"> + <record id="deadline_notification_email_template" model="mail.template"> + <field name="name">Task Deadline Email Template</field> + <field name="email_from">erp_system@kci-global.com.tw</field> + <field name="subject">[KCI ERP System]撠���遙��䠷�𡁶䰻</field> + <field name="model_id" ref="project.model_project_task"/> + <field name="auto_delete" eval="False"/> + <field name="body_html" type="html"> + <div>test</div> + </field> + </record> + </data> +</odoo> diff --git a/extra-addons/kci-project/models/project.py b/extra-addons/kci-project/models/project.py index eb36b1ffbcc92aec4cca504a2b56a980290f62c7..5af7b90d3adfd33c02606f90f29ea1a371889704 100644 --- a/extra-addons/kci-project/models/project.py +++ b/extra-addons/kci-project/models/project.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +import datetime from odoo import api, fields, models, _ @@ -19,9 +20,78 @@ class ProjectTask(models.Model): tech_tag_ids = fields.Many2many('project.tech.tag', 'task_tech_tag_rel', 'tech_tag_id', 'project_task_id', string='Tech. Type') resource_request = fields.Many2one('res.users', string='resource request', tracking=True) - + manufacture_data = fields.Many2many('mrp.production') + @api.onchange('stage_id') + def _task_stage_check(self): + self.project_id._task_stage_check(self, self.stage_id) + + def cron_deadline_check(self): + today = datetime.date.today() + tasks = self.env['project.task'].search([]) + projects = self.env['project.project'].search([]) + for task in tasks: + if task.date_deadline: + if task.kanban_state != 'done': + if today >= task.date_deadline: + task.update({ + 'kanban_state': 'blocked', + }) + else: + task.update({ + 'kanban_state': 'normal', + }) + + for project in projects: + for task in project.task_ids: + if task.kanban_state == 'blocked': + project.update({ + 'last_update_status': 'off_track', + }) + break + else: + project.update({ + 'last_update_status': 'on_track', + }) + + def cron_deadline_notification_check(self): + today = datetime.date.today() + tasks = self.env['project.task'].search([]) + for task in tasks: + if task.date_deadline: + if task.kanban_state != 'done': + due_days = (task.date_deadline - today).days + if due_days == 7: + self.action_send_notification(task, due_days) + elif due_days <= 3: + self.action_send_notification(task, due_days) + + def action_send_notification(self, task, due_days): + url = f"/web#id={task.id}&view_type=form&model=project.task" + if due_days == 0: + message = f"撠��� {task.project_id.name} 隞餃�� <a href='{self.env['ir.config_parameter'].sudo().get_param('web.base.url')}{url}'>{task.name}</a> 撠�䲰隞𦠜𠯫�����" + elif due_days < 0: + message = f"撠��� {task.project_id.name} 隞餃�� <a href='{self.env['ir.config_parameter'].sudo().get_param('web.base.url')}{url}'>{task.name}</a> 撌脤�擧�� {abs(due_days)} �𠯫" + else: + message = f"撠��� {task.project_id.name} 隞餃�� <a href='{self.env['ir.config_parameter'].sudo().get_param('web.base.url')}{url}'>{task.name}</a> ��擗� {due_days} �𠯫�����" + email_to = '' + for partner in task.user_ids: + email_to += f'{partner.email}, ' + email_values = { + 'email_to': email_to, + 'email_from': "erp_system@kci-global.com.tw", + 'body_html': message, + } + mail_template = self.env.ref('kci-project.deadline_notification_email_template') + mail_template.send_mail(self.id, force_send=True, email_values=email_values) + + def write(self, vals): + if self.kanban_state == 'done': + vals['kanban_state'] = 'done' + res = super(ProjectTask, self).write(vals) + return res + class Project(models.Model): _inherit = 'project.project' @@ -34,6 +104,22 @@ class Project(models.Model): sales_data = fields.Many2many('sale.order') bom_data = fields.Many2many('mrp.bom') + def _task_stage_check(self, changed_task, new_task_stage): + origin_task = self.env['project.task'].browse(str(changed_task.id)[6:]) + for type_id in self.type_ids: + tasks = list(self.env['project.task'].search([('project_id', '=', self.id), ('stage_id', '=', type_id.id)])) + for task in tasks: + if str(origin_task.id) == str(task.id): + tasks.remove(task) + if type_id == new_task_stage: + tasks += origin_task + if tasks: + for project in self: + project.update({ + 'stage_id': self.env['project.project.stage'].search([('name', '=', type_id.name), ])[0].id, + }) + break + # class PurchaseOrder(models.Model): # _inherit = 'purchase.order' diff --git a/extra-addons/kci-project/security/ir.model.access.csv b/extra-addons/kci-project/security/ir.model.access.csv new file mode 100644 index 0000000000000000000000000000000000000000..d510d5e83a82c51805c9e5b23496349d814e6ca2 --- /dev/null +++ b/extra-addons/kci-project/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_project_tech_tag_user,Project Tech Tag User Access,model_project_tech_tag,project_tech_tag_group_user,1,0,0,0 +access_project_tech_tag_manager,Project Tech Tag Manager Access,model_project_tech_tag,project_tech_tag_group_manager,1,1,1,1 \ No newline at end of file diff --git a/extra-addons/kci-project/security/security.xml b/extra-addons/kci-project/security/security.xml new file mode 100644 index 0000000000000000000000000000000000000000..183a843c612471e9568e17c2c2b888f13bb4b28e --- /dev/null +++ b/extra-addons/kci-project/security/security.xml @@ -0,0 +1,24 @@ +<odoo> + <record id="project_tech_tag_group" model="ir.module.category"> + <field name="name">Project Tech Tag</field> + </record> + + <record id="project_tech_tag_group_user" model="res.groups"> + <field name="name">User</field> + <field name="category_id" + ref="project_tech_tag_group"/> + <field name="implied_ids" + eval="[(4, ref('base.group_user'))]"/> + </record> + + <record id="project_tech_tag_group_manager" model="res.groups"> + <field name="name">Manager</field> + <field name="category_id" + ref="project_tech_tag_group"/> + <field name="implied_ids" + eval="[(4, ref('project_tech_tag_group'))]"/> + <field name="users" + eval="[(4, ref('base.user_root')), + (4, ref('base.user_admin'))]"/> + </record> +</odoo> \ No newline at end of file diff --git a/extra-addons/kci-purchase/__manifest__.py b/extra-addons/kci-purchase/__manifest__.py index c9f91cc565b9bf186ec5a6608fdfb32138579d02..d31340ba48137ab8fb0ed4a7dd3fed2fb557d1bc 100644 --- a/extra-addons/kci-purchase/__manifest__.py +++ b/extra-addons/kci-purchase/__manifest__.py @@ -17,6 +17,7 @@ This module contains all the common features of project. 'views/internal_purchase_views.xml', 'views/purchase_views.xml', 'views/purchase_groups.xml', + 'data/internal_purchase_email.xml', ], 'application': True, 'installable': True, diff --git a/extra-addons/kci-purchase/data/internal_purchase_email.xml b/extra-addons/kci-purchase/data/internal_purchase_email.xml new file mode 100644 index 0000000000000000000000000000000000000000..392c1e51cfc97e724ff3b0623ca518e56811ca96 --- /dev/null +++ b/extra-addons/kci-purchase/data/internal_purchase_email.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <data noupdate="1"> + <record id="internal_purchase_email_template" model="mail.template"> + <field name="name">Internal Purchase Email Template</field> + <field name="email_from">erp_system@kci-global.com.tw</field> + <field name="subject">[KCI ERP System] BOM1 �𡁶䰻</field> + <field name="model_id" ref="kci-purchase.model_purchase_internal_order"/> + <field name="auto_delete" eval="False"/> + <field name="body_html" type="html"> + <div>test</div> + </field> + </record> + </data> +</odoo> diff --git a/extra-addons/kci-purchase/models/internal_purchase.py b/extra-addons/kci-purchase/models/internal_purchase.py index 0ba4321acab76c4e8b0dd96230f605b0abd2016b..b10587d37389405074cef06531f25bf88ef42a98 100644 --- a/extra-addons/kci-purchase/models/internal_purchase.py +++ b/extra-addons/kci-purchase/models/internal_purchase.py @@ -23,9 +23,6 @@ class InternalPurchaseOrder(models.Model): This function create a bom-1 for estimate a case. ''' product = self.env['product.product'].create({'name': self.inquiry_id['name'], 'product_type': 'project'}) - print(product) - for i in product: - print(i) if self.inquiry_id['type'] == 'project': bom = self.env['mrp.bom'].create({ 'product_tmpl_id': product.product_tmpl_id.id, @@ -63,7 +60,7 @@ class InternalPurchaseOrder(models.Model): 'notification_type': 'inbox'}))] user_id = self.env.user.id url = f"/web#id={bom_id.id}&view_type=form&model=mrp.bom" - message = f"撌脣遣蝡� BOM <a href='{url}'>{bom_id.product_tmpl_id.name}</a> " + message = f"撌脣遣蝡� BOM <a href='{self.env['ir.config_parameter'].sudo().get_param('web.base.url')}{url}'>{bom_id.product_tmpl_id.name}</a> " group = self.env['mail.channel'].search([('group_public_id', '=', self.env.ref('kci-mrp.kci_mrp_group').id)]) if case_type == 'project' else self.env['mail.channel'].search([('group_public_id', '=', self.env.ref('sales.kci_sales_manager_group').id)]) group.message_post(author_id=user_id, body=message + "隢𧢲䰻�𤣰", @@ -74,13 +71,24 @@ class InternalPurchaseOrder(models.Model): notify_by_email=False, ) self.env['res.partner'].browse(user_id).message_post(author_id=user_id, - body=message + "撌脣���", - message_type='notification', - subtype_xmlid="mail.mt_comment", - notification_ids=notification_ids, - partner_ids=[self.env.user.id], - notify_by_email=False, - ) + body=message + "撌脣���", + message_type='notification', + subtype_xmlid="mail.mt_comment", + notification_ids=notification_ids, + partner_ids=[self.env.user.id], + notify_by_email=False, + ) + email_to = '' + for partner in group.channel_partner_ids: + email_to += f'{partner.email}, ' + email_values = { + 'email_to': email_to, + 'email_cc': self.env.user.partner_id.email, + 'email_from': "erp_system@kci-global.com.tw", + 'body_html': message, + } + mail_template = self.env.ref('kci-purchase.internal_purchase_email_template') + mail_template.send_mail(self.id, force_send=True, email_values=email_values) class InternalPurchaseOrderLine(models.Model): diff --git a/extra-addons/kci-purchase/models/purchase.py b/extra-addons/kci-purchase/models/purchase.py index a998140fb80251b754609256bfe84f06955c2614..ae4d031354c58d1ba6c1934d9d195012b97ef534 100644 --- a/extra-addons/kci-purchase/models/purchase.py +++ b/extra-addons/kci-purchase/models/purchase.py @@ -11,6 +11,15 @@ class PurchaseOrder(models.Model): contract_email = fields.Char(string='�舐窗鈭粹𤓖摮𣂷縑蝞�', size=100) contract_phone = fields.Char(string='�舐窗鈭粹𤓖閰�', size=100) + @api.onchange('partner_id') + def _refresh_supply_data(self): + self.update({ + 'contract_name': self.partner_id.name, + 'contract_department': self.partner_id.department, + 'contract_email': self.partner_id.email, + 'contract_phone': self.partner_id.phone, + }) + @api.model def create(self, vals): company_id = vals.get('company_id', self.default_get(['company_id'])['company_id']) diff --git a/extra-addons/kci-purchase/views/purchase_views.xml b/extra-addons/kci-purchase/views/purchase_views.xml index 4beed9391d1cf03894ea9ccbfa929d5b71ae8c24..23c32240d8de99f625fd0dd815c987289f047f39 100644 --- a/extra-addons/kci-purchase/views/purchase_views.xml +++ b/extra-addons/kci-purchase/views/purchase_views.xml @@ -10,6 +10,18 @@ <field name="contract_email"/> <field name="contract_phone"/> </xpath> + + <xpath expr="//field[@name='date_order']" position="replace"> + <field name="date_order" attrs="{'invisible': [('state','in',('purchase','done'))]}" invisible="1"/> + </xpath> + + <xpath expr="//div[@name='date_planned_div']" position="replace"> + <div name="date_planned_div" class="o_row"> + <field name="date_planned" attrs="{'readonly': [('state', 'not in', ('draft', 'sent', 'to approve', 'purchase'))]}" widget="date"/> + <field name="mail_reminder_confirmed" invisible="1"/> + <span class="text-muted" attrs="{'invisible': [('mail_reminder_confirmed', '=', False)]}">(confirmed by vendor)</span> + </div> + </xpath> </field> </record> </odoo> \ No newline at end of file diff --git a/extra-addons/sales/__manifest__.py b/extra-addons/sales/__manifest__.py index c9781bad29dfc357b41349d62732832c2ba1a15a..6314f87e4843d1f9545651a0a6451d566a5522e3 100644 --- a/extra-addons/sales/__manifest__.py +++ b/extra-addons/sales/__manifest__.py @@ -10,7 +10,7 @@ 'description': """ This module contains all the common features of Sales Management and eCommerce. """, - 'depends': ['sale', 'sales_team', 'payment', 'portal', 'utm', 'mrp', 'purchase'], + 'depends': ['sale', 'sales_team', 'payment', 'portal', 'utm', 'mrp', 'purchase', 'mail'], 'data': [ 'security/security.xml', 'security/ir.model.access.csv', @@ -18,6 +18,7 @@ This module contains all the common features of Sales Management and eCommerce. 'views/inquiry_menu.xml', 'views/views.xml', 'views/sales_groups.xml', + 'data/inquiry_email.xml', ], 'application': True, 'installable': True, diff --git a/extra-addons/sales/data/inquiry_email.xml b/extra-addons/sales/data/inquiry_email.xml new file mode 100644 index 0000000000000000000000000000000000000000..337f919af0ed3e62abb5ad24addd836ba8087f35 --- /dev/null +++ b/extra-addons/sales/data/inquiry_email.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <data noupdate="1"> + <record id="inquiry_email_template" model="mail.template"> + <field name="name">INQUIRY Email Template</field> + <field name="email_from">erp_system@kci-global.com.tw</field> + <field name="subject">[KCI ERP System]�折�刻岷�孵鱓�𡁶䰻</field> + <field name="model_id" ref="sales.model_sales_inquiry"/> + <field name="auto_delete" eval="False"/> + <field name="body_html" type="html"> + <div>test</div> + </field> + </record> + </data> +</odoo> diff --git a/extra-addons/sales/models/inquiry_model.py b/extra-addons/sales/models/inquiry_model.py index 9087d5419da3b0f384a482f36f04af20ddbd29d5..ee4371f29ba4f0faa1f0202e67b09efd1c3a0b8d 100644 --- a/extra-addons/sales/models/inquiry_model.py +++ b/extra-addons/sales/models/inquiry_model.py @@ -54,9 +54,6 @@ class Inquiry(models.Model): 'operation': 'O', 'project': 'P' } - # print(self.env['hr.employee'].search([('user_id', '=', self.env.user)]) if self.env['hr.employee'].search([('user_id', '=', self.env.user)]) else self.env.user) - print(self.env.user) - print(self.env['hr.employee'].search([('user_id', '=', self.env.user.id)]).sales_id) date = datetime.now() serial_number = len(self.env['sales.inquiry'].search([('code', 'like', f"{type_mapping[self.type]}-{str(date.year)[2:]}{date.month if date.month > 9 else '0' + str(date.month)}-{self.sales_person.sales_id if self.sales_person.sales_id else '00'}")])) serial = f'00{serial_number + 1}' if serial_number < 9 else f'0{serial_number + 1}' @@ -64,9 +61,11 @@ class Inquiry(models.Model): @api.onchange('customer') def _refresh_customer_data(self): - self.factory = self.customer.factory - self.department = self.customer.department - self.customer_com = self.customer.parent_id + self.update({ + 'factory': self.customer.factory, + 'department': self.customer.department, + 'customer_com': self.customer.parent_id, + }) @api.model def create(self, vals): @@ -81,7 +80,7 @@ class Inquiry(models.Model): 'notification_type': 'inbox'}))] user_id = self.env.user.id url = f"/web#id={internal_order.id}&view_type=form&model=purchase.internal.order" - message = f"撌脣遣蝡见�折�刻岷�孵鱓 {internal_order.order_code} <a href='{url}'>{internal_order.name}</a> " + message = f"撌脣遣蝡见�折�刻岷�孵鱓 {internal_order.order_code} <a href='{self.env['ir.config_parameter'].sudo().get_param('web.base.url')}{url}'>{internal_order.name}</a> " group = self.env['mail.channel'].search([('group_public_id', '=', self.env.ref('kci-purchase.kci_purchase_group').id)]) group.message_post(author_id=user_id, body=message + "隢𧢲䰻�𤣰", @@ -89,16 +88,31 @@ class Inquiry(models.Model): subtype_xmlid="mail.mt_comment", notification_ids=notification_ids, partner_ids=[self.env.user.id], - notify_by_email=False, + email_from="rex.wu@kci-global.com.tw", + subject="[KCI ERP System]�折�刻岷�孵鱓�𡁶䰻", + notify_by_email=True, ) self.env["res.partner"].browse(self.env.user.partner_id.id).message_post(author_id=user_id, - body=message + "撌脣���", - message_type='notification', - subtype_xmlid="mail.mt_comment", - notification_ids=notification_ids, - partner_ids=[self.env.user.id], - notify_by_email=False, - ) + body=message + "撌脣���", + message_type='notification', + subtype_xmlid="mail.mt_comment", + notification_ids=notification_ids, + partner_ids=[self.env.user.id], + email_from="rex.wu@kci-global.com.tw", + subject="[KCI ERP System]�折�刻岷�孵鱓�𡁶䰻", + notify_by_email=True, + ) + email_to = '' + for partner in group.channel_partner_ids: + email_to += f'{partner.email}, ' + email_values = { + 'email_to': email_to, + 'email_cc': self.env.user.partner_id.email, + 'email_from': "erp_system@kci-global.com.tw", + 'body_html': message, + } + mail_template = self.env.ref('sales.inquiry_email_template') + mail_template.send_mail(self.id, force_send=True, email_values=email_values) # self.env['mail.message'].create({ # 'email_from': self.env.user.partner_id.email, # add the sender email