Commit 3bc48c45 authored by rex wu's avatar rex wu
Browse files

Merge branch 'project' into '15.0'

fixed(bom): bom2 email to purchase

See merge request !70
2 merge requests!7115.0,!70fixed(bom): bom2 email to purchase
Showing with 15 additions and 2 deletions
+15 -2
......@@ -65,6 +65,12 @@ class Bom(models.Model):
is_create=True,
url=f'/web#id={new_bom.id}&view_type=form&model=mrp.bom')
def action_bom2_for_purchase(self):
self.action_send_bom_notification(bom_name=self.product_tmpl_id.name,
is_create=False,
is_purchase=True,
url=f'/web#id={self.id}&view_type=form&model=mrp.bom')
def action_create_quotation(self):
quotation = self.env['sale.order'].create({
'name': self.product_tmpl_id.name,
......@@ -122,13 +128,19 @@ class Bom(models.Model):
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):
def action_send_bom_notification(self, bom_name, is_create, url, is_purchase=False):
# 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='{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)])
if is_create:
group_public = self.env.ref('sales.kci_sales_manager_group')
elif is_purchase:
group_public = self.env.ref('kci-purchase.kci_purchase_group')
else:
group_public = self.env.ref('kci-mrp.kci_mrp_manager_group')
group = self.env['mail.channel'].search([('group_public_id', '=', group_public.id)])
# group.message_post(author_id=user_id,
# body=message + "請查收",
# message_type='notification',
......
......@@ -14,6 +14,7 @@
<xpath expr="//div[@name='button_box']" position="inside">
<button name="action_bom1_to_quotation" action="action_bom1_to_quotation" string="產生報價 BOM 表" type="object" icon="fa-file" class="oe_stat_button" attrs="{'invisible': [('status', '!=', 'internal')]}"/>
<button name="action_create_quotation" action="action_create_quotation" string="產生報價單" type="object" icon="fa-dollar" class="oe_stat_button" attrs="{'invisible': [('status', '!=', 'quotation')]}"/>
<button name="action_bom2_for_purchase" action="action_bom2_for_purchase" string="通知採購" type="object" icon="fa-file" class="oe_stat_button" attrs="{'invisible': [('status', '!=', 'external')]}"/>
</xpath>
<xpath expr="//field[@name='product_id']" position="after">
<field name="project_id"/>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment