File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ class BaseCommentTemplate(models.Model):
4242 help = "If set, the comment template will be available only for the selected "
4343 "company." ,
4444 )
45+ global_template = fields .Boolean ()
4546 partner_ids = fields .Many2many (
4647 comodel_name = "res.partner" ,
4748 relation = "base_comment_template_res_partner_rel" ,
Original file line number Diff line number Diff line change @@ -41,7 +41,11 @@ def _compute_comment_template_ids(self):
4141 templates = template_model .search (
4242 expression .AND (
4343 [
44- [("id" , "in" , partner .base_comment_template_ids .ids )],
44+ [
45+ "|" ,
46+ ("id" , "in" , partner .base_comment_template_ids .ids ),
47+ ("global_template" , "=" , True ),
48+ ],
4549 template_domain ,
4650 ]
4751 )
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ class ResPartner(models.Model):
1414 column1 = "res_partner_id" ,
1515 column2 = "base_comment_template_id" ,
1616 string = "Comment Templates" ,
17+ domain = [("global_template" , "=" , False )],
1718 help = "Specific partner comments that can be included in reports" ,
1819 )
1920
Original file line number Diff line number Diff line change @@ -87,6 +87,23 @@ def test_general_template(self):
8787 self .assertTrue (self .before_template_id in self .user .comment_template_ids )
8888 self .assertTrue (self .after_template_id in self .user .comment_template_ids )
8989
90+ def test_global_template (self ):
91+ # Need to force _compute because only trigger when partner_id have changed
92+ global_template = self .env ["base.comment.template" ].create (
93+ {
94+ "name" : "Top template" ,
95+ "text" : "Text before lines" ,
96+ "models" : self .user_obj .model ,
97+ "company_id" : self .company .id ,
98+ }
99+ )
100+ self .user ._compute_comment_template_ids ()
101+ # Check getting default comment template
102+ self .assertNotIn (global_template , self .user .comment_template_ids )
103+ global_template .global_template = True
104+ self .user ._compute_comment_template_ids ()
105+ self .assertIn (global_template , self .user .comment_template_ids )
106+
90107 def test_partner_template (self ):
91108 self .partner2_id .base_comment_template_ids = [
92109 (4 , self .before_template_id .id ),
Original file line number Diff line number Diff line change 1010 <field name =" position" />
1111 <field name =" company_id" groups =" base.group_multi_company" />
1212 <field name =" partner_ids" />
13+ <field name =" global_template" />
1314 <field name =" models" />
1415 <field name =" model_ids" groups =" base.group_erp_manager" />
1516 <field name =" domain" />
7172 <field name =" domain" />
7273 <field name =" models" />
7374 <field name =" partner_ids" widget =" many2many_tags" />
75+ <field name =" global_template" />
7476 <field name =" engine" groups =" base.group_no_one" />
7577 </group >
7678 </group >
You can’t perform that action at this time.
0 commit comments