Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
rex wu
odoo
Commits
32ac6632
Commit
32ac6632
authored
1 year ago
by
rexwu
Browse files
Options
Download
Email Patches
Plain Diff
feat(project): some feature on 8/7 meeting
parent
215cd54a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
extra-addons/kci-mrp/models/mrp_bom.py
+31
-2
extra-addons/kci-mrp/models/mrp_bom.py
extra-addons/kci-purchase/models/internal_purchase.py
+17
-2
extra-addons/kci-purchase/models/internal_purchase.py
extra-addons/kci-purchase/views/internal_purchase_views.xml
+19
-19
extra-addons/kci-purchase/views/internal_purchase_views.xml
extra-addons/kci-purchase/views/purchase_views.xml
+12
-0
extra-addons/kci-purchase/views/purchase_views.xml
extra-addons/sales/models/inquiry_model.py
+8
-0
extra-addons/sales/models/inquiry_model.py
with
87 additions
and
23 deletions
+87
-23
extra-addons/kci-mrp/models/mrp_bom.py
+
31
-
2
View file @
32ac6632
...
...
@@ -19,10 +19,39 @@ class Bom(models.Model):
inquiry_id
=
fields
.
Many2one
(
'sales.inquiry'
,
string
=
'廠勘表'
,
tracking
=
True
,
default
=
False
)
purchase_id
=
fields
.
Many2one
(
'purchase.internal.order'
,
string
=
'採購'
)
date
=
fields
.
Date
(
'date
'
,
default
=
fields
.
Datetime
.
now
,
tracking
=
True
)
user_id
=
fields
.
Many2one
(
'res.users'
,
string
=
'
Engineer
'
,
tracking
=
True
,
default
=
lambda
self
:
self
.
env
.
user
)
date
=
fields
.
Date
(
string
=
'日期
'
,
default
=
fields
.
Datetime
.
now
,
tracking
=
True
)
user_id
=
fields
.
Many2one
(
'res.users'
,
string
=
'
工程師
'
,
tracking
=
True
,
default
=
lambda
self
:
self
.
env
.
user
)
customer_id
=
fields
.
Many2one
(
'res.partner'
,
string
=
'客戶'
)
@
api
.
onchange
(
'user_id'
)
def
_assign_engineer
(
self
):
notification_ids
=
[((
0
,
0
,
{
'res_partner_id'
:
self
.
env
.
user
.
partner_id
.
id
,
'notification_type'
:
'inbox'
}))]
url
=
f
'/web#id=
{
self
.
id
}
&view_type=form&model=mrp.bom'
bom_name
=
self
.
product_tmpl_id
.
name
user_id
=
self
.
env
.
user
.
id
message
=
f
"已被指派為 BOM <a href='
{
self
.
env
[
'ir.config_parameter'
].
sudo
().
get_param
(
'web.base.url'
)
}{
url
}
'>
{
bom_name
}
</a> 工程師"
self
.
user_id
.
partner_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
,
)
email_values
=
{
'email_to'
:
self
.
user_id
.
partner_id
.
email
,
'email_cc'
:
self
.
env
.
user
.
partner_id
.
email
,
'email_from'
:
"erp_system@kci-global.com.tw"
,
'subject'
:
'[KCI ERP System] BOM 通知'
,
'body_html'
:
message
,
}
print
(
'----------------------'
)
print
(
self
.
user_id
.
partner_id
.
email
)
mail_template
=
self
.
env
.
ref
(
'kci-mrp.bom_email_template'
)
mail_template
.
send_mail
(
self
.
ids
[
0
],
force_send
=
True
,
email_values
=
email_values
)
def
write
(
self
,
vals
):
if
self
.
status
==
'internal'
:
self
.
action_send_bom_notification
(
bom_name
=
self
.
product_tmpl_id
.
name
,
...
...
This diff is collapsed.
Click to expand it.
extra-addons/kci-purchase/models/internal_purchase.py
+
17
-
2
View file @
32ac6632
...
...
@@ -17,6 +17,8 @@ class InternalPurchaseOrder(models.Model):
inquiry_id
=
fields
.
Many2one
(
'sales.inquiry'
,
string
=
'詢價單'
)
bom_id
=
fields
.
Many2one
(
'mrp.bom'
,
string
=
'bom'
)
order_line
=
fields
.
One2many
(
'purchase.order.line'
,
'internal_order_id'
,
string
=
'項目'
,
copy
=
True
)
assigned_engineer
=
fields
.
Many2one
(
'res.users'
,
string
=
'指定工程師'
)
project
=
fields
.
Many2one
(
'project.project'
,
default
=
False
)
def
action_bom_request
(
self
):
'''
...
...
@@ -32,7 +34,9 @@ class InternalPurchaseOrder(models.Model):
'status'
:
'internal'
,
'customer_id'
:
self
.
inquiry_id
[
'customer'
].
id
,
'inquiry_id'
:
self
.
inquiry_id
.
id
,
'purchase_id'
:
self
.
id
'purchase_id'
:
self
.
id
,
'user_id'
:
self
.
assigned_engineer
.
id
,
'project_id'
:
self
.
project
.
id
,
})
# and mention engineer
else
:
...
...
@@ -62,6 +66,7 @@ class InternalPurchaseOrder(models.Model):
'res_partner_id'
:
self
.
env
.
user
.
partner_id
.
id
,
'notification_type'
:
'inbox'
}))]
user_id
=
self
.
env
.
user
.
id
email_to
=
''
url
=
f
"/web#id=
{
bom_id
.
id
}
&view_type=form&model=mrp.bom"
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
)])
...
...
@@ -81,7 +86,17 @@ class InternalPurchaseOrder(models.Model):
partner_ids
=
[
self
.
env
.
user
.
id
],
notify_by_email
=
False
,
)
email_to
=
''
if
self
.
assigned_engineer
:
email_to
+=
f
'
{
self
.
assigned_engineer
.
email
}
, '
self
.
assigned_engineer
.
partner_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
,
)
for
partner
in
group
.
channel_partner_ids
:
email_to
+=
f
'
{
partner
.
email
}
, '
email_values
=
{
...
...
This diff is collapsed.
Click to expand it.
extra-addons/kci-purchase/views/internal_purchase_views.xml
+
19
-
19
View file @
32ac6632
...
...
@@ -35,8 +35,7 @@
</button>
</div>
<div
class=
"oe_title"
>
<span
class=
"o_form_label"
attrs=
"{'invisible': [('state','not in',('draft','sent'))]}"
>
Request for Quotation
</span>
<span
class=
"o_form_label"
attrs=
"{'invisible': [('state','in',('draft','sent'))]}"
>
Purchase Order
</span>
<span
class=
"o_form_label"
>
內部詢價單
</span>
<h1>
<field
name=
"priority"
widget=
"priority"
class=
"mr-3"
/>
<field
name=
"name"
readonly=
"1"
/>
...
...
@@ -46,25 +45,26 @@
<group>
<field
name=
"order_code"
/>
<field
name=
"partner_id"
widget=
"res_partner_many2one"
context=
"{'res_partner_search_mode': 'supplier', 'show_vat': True}"
placeholder=
"Name, TIN, Email, or Reference"
placeholder=
"Name, TIN, Email, or Reference"
string=
"供應商"
/>
<field
name=
"partner_ref"
/>
<field
name=
"partner_ref"
string=
"供應商資料"
/>
<field
name=
"currency_id"
groups=
"base.group_multi_currency"
force_save=
"1"
/>
<field
name=
"id"
invisible=
"1"
/>
<field
name=
"inquiry_id"
widget=
"many2one"
/>
<field
name=
"bom_id"
widget=
"many2one"
readonly=
"1"
/>
</group>
<group>
<field
name=
"date_order"
attrs=
"{'invisible': [('state','in',('purchase','done'))]}"
/>
<label
for=
"date_approve"
attrs=
"{'invisible': [('state','not in',('purchase','done'))]}"
/>
<field
name=
"date_order"
attrs=
"{'invisible': [('state','in',('purchase','done'))]}"
invisible=
"1"
/>
<label
for=
"date_approve"
attrs=
"{'invisible': [('state','not in',('purchase','done'))]}"
invisible=
"1"
/>
<div
name=
"date_approve"
attrs=
"{'invisible': [('state','not in',('purchase','done'))]}"
class=
"o_row"
>
<field
name=
"date_approve"
/>
<field
name=
"mail_reception_confirmed"
invisible=
"1"
/>
<span
class=
"text-muted"
attrs=
"{'invisible': [('mail_reception_confirmed','=', False)]}"
>
(confirmed by vendor)
</span>
</div>
<label
for=
"date_planned"
/>
<field
name=
"assigned_engineer"
widget=
"many2one"
/>
<label
for=
"date_planned"
string=
"承諾供貨日期"
/>
<div
name=
"date_planned_div"
class=
"o_row"
>
<field
name=
"date_planned"
attrs=
"{'readonly': [('state', 'not in', ('draft', 'sent', 'to approve', 'purchase'))]}"
/>
<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>
...
...
@@ -81,7 +81,7 @@
</group>
</group>
<notebook>
<page
string=
"
Products
"
name=
"products"
>
<page
string=
"
產品
"
name=
"products"
>
<field
name=
"tax_country_id"
invisible=
"1"
/>
<field
name=
"order_line"
widget=
"section_and_note_one2many"
...
...
@@ -90,9 +90,9 @@
attrs=
"{'readonly': [('state', 'in', ('done', 'cancel'))]}"
>
<tree
string=
"Purchase Order Lines"
editable=
"bottom"
>
<control>
<create
name=
"add_product_control"
string=
"
Add a product
"
/>
<create
name=
"add_section_control"
string=
"Add a section"
context=
"{'default_display_type': 'line_section'}"
/>
<create
name=
"add_note_control"
string=
"Add a note"
context=
"{'default_display_type': 'line_note'}"
/>
<create
name=
"add_product_control"
string=
"
增加商品
"
/>
<!--
<create name="add_section_control" string="Add a section" context="{'default_display_type': 'line_section'}"/>
-->
<!--
<create name="add_note_control" string="Add a note" context="{'default_display_type': 'line_note'}"/>
-->
</control>
<field
name=
"display_type"
invisible=
"1"
/>
<field
name=
"currency_id"
invisible=
"1"
/>
...
...
@@ -240,17 +240,17 @@
</group>
<div
class=
"oe_clear"
/>
</page>
<page
string=
"
Other Information
"
name=
"purchase_delivery_invoice"
>
<page
string=
"
其他資訊
"
name=
"purchase_delivery_invoice"
>
<group>
<group
name=
"other_info"
>
<field
name=
"user_id"
domain=
"[('share', '=', False)]"
widget=
"many2one_avatar_user"
/>
<field
name=
"user_id"
domain=
"[('share', '=', False)]"
widget=
"many2one_avatar_user"
string=
"採購人員"
/>
<field
name=
"company_id"
groups=
"base.group_multi_company"
options=
"{'no_create': True}"
/>
<field
name=
"origin"
/>
<field
name=
"origin"
string=
"來源單據"
/>
</group>
<group
name=
"invoice_info"
>
<field
name=
"invoice_status"
attrs=
"{'invisible': [('state', 'in', ('draft', 'sent', 'to approve', 'cancel'))]}"
/>
<field
name=
"payment_term_id"
attrs=
"{'readonly': ['|', ('invoice_status','=', 'invoiced'), ('state', '=', 'done')]}"
options=
"{'no_create': True}"
/>
<field
name=
"fiscal_position_id"
options=
"{'no_create': True}"
attrs=
"{'readonly': ['|', ('invoice_status','=', 'invoiced'), ('state', '=', 'done')]}"
/>
<field
name=
"invoice_status"
attrs=
"{'invisible': [('state', 'in', ('draft', 'sent', 'to approve', 'cancel'))]}"
string=
"帳單狀態"
/>
<field
name=
"payment_term_id"
attrs=
"{'readonly': ['|', ('invoice_status','=', 'invoiced'), ('state', '=', 'done')]}"
options=
"{'no_create': True}"
string=
"付款條件"
/>
<field
name=
"fiscal_position_id"
options=
"{'no_create': True}"
attrs=
"{'readonly': ['|', ('invoice_status','=', 'invoiced'), ('state', '=', 'done')]}"
string=
"財政狀況"
/>
</group>
</group>
</page>
...
...
@@ -339,7 +339,7 @@
</record>
<record
id=
"purchase_internal_form_action"
model=
"ir.actions.act_window"
>
<field
name=
"name"
>
Internal Purchase Orders
</field>
<field
name=
"name"
>
內部詢價單
</field>
<field
name=
"type"
>
ir.actions.act_window
</field>
<field
name=
"res_model"
>
purchase.internal.order
</field>
<field
name=
"view_mode"
>
tree,kanban,form,pivot,graph,activity
</field>
...
...
This diff is collapsed.
Click to expand it.
extra-addons/kci-purchase/views/purchase_views.xml
+
12
-
0
View file @
32ac6632
...
...
@@ -22,6 +22,18 @@
<span
class=
"text-muted"
attrs=
"{'invisible': [('mail_reminder_confirmed', '=', False)]}"
>
(confirmed by vendor)
</span>
</div>
</xpath>
<xpath
expr=
"//label[@for='date_approve']"
position=
"attributes"
>
<attribute
name=
"invisible"
>
1
</attribute>
</xpath>
<xpath
expr=
"//div[@name='date_approve']"
position=
"replace"
>
<div
name=
"date_approve"
attrs=
"{'invisible': [('state','not in',('purchase','done'))]}"
class=
"o_row"
invisible=
"1"
>
<field
name=
"date_approve"
/>
<field
name=
"mail_reception_confirmed"
invisible=
"1"
/>
<span
class=
"text-muted"
attrs=
"{'invisible': [('mail_reception_confirmed','=', False)]}"
>
(confirmed by vendor)
</span>
</div>
</xpath>
</field>
</record>
</odoo>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
extra-addons/sales/models/inquiry_model.py
+
8
-
0
View file @
32ac6632
...
...
@@ -23,6 +23,7 @@ class Inquiry(models.Model):
purchase_data
=
fields
.
Many2one
(
'purchase.order'
,
tracking
=
True
,
string
=
'採購'
,
default
=
False
)
internal_purchase
=
fields
.
Many2one
(
'purchase.internal.order'
,
string
=
'內部詢價單'
,
default
=
False
)
bom_data
=
fields
.
Many2one
(
'mrp.bom'
,
tracking
=
True
,
string
=
'BOM'
,
default
=
False
)
project
=
fields
.
Many2one
(
'project.project'
,
default
=
False
)
sales_manager
=
fields
.
Many2one
(
'hr.employee'
,
tracking
=
True
,
string
=
'業務主管'
)
sales_person
=
fields
.
Many2one
(
'hr.employee'
,
default
=
lambda
self
:
self
.
env
[
'hr.employee'
].
search
([(
'user_id'
,
'='
,
self
.
env
.
user
.
id
)]).
id
,
tracking
=
True
,
string
=
'業務人員'
)
customer_com
=
fields
.
Many2one
(
'res.partner'
,
string
=
'公司'
)
...
...
@@ -71,6 +72,13 @@ class Inquiry(models.Model):
def
create
(
self
,
vals
):
result
=
super
(
Inquiry
,
self
).
create
(
vals
)
internal_order
=
self
.
env
[
'purchase.internal.order'
].
create
({
'name'
:
result
.
name
,
'order_code'
:
result
.
code
,
'inquiry_id'
:
result
.
id
})
result
.
internal_purchase
=
internal_order
if
result
.
type
==
'project'
:
project
=
self
.
env
[
'project.project'
].
create
({
'name'
:
result
.
name
})
result
.
project
=
project
internal_order
.
update
({
'project'
:
project
.
id
})
self
.
action_send_notification
(
internal_order
)
return
result
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help