File: res_config_settings.py

package info (click to toggle)
odoo 18.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 878,716 kB
  • sloc: javascript: 927,937; python: 685,670; xml: 388,524; sh: 1,033; sql: 415; makefile: 26
file content (31 lines) | stat: -rw-r--r-- 1,299 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding: utf-8 -*-	
# Part of Odoo. See LICENSE file for full copyright and licensing details.	

from odoo import api, fields, models


class ResConfigSettings(models.TransientModel):	
    _inherit = 'res.config.settings'	

    snailmail_color = fields.Boolean(string='Print In Color', related='company_id.snailmail_color', readonly=False)
    snailmail_cover = fields.Boolean(string='Add a Cover Page', related='company_id.snailmail_cover', readonly=False)
    snailmail_duplex = fields.Boolean(string='Print Both sides', related='company_id.snailmail_duplex', readonly=False)

    snailmail_cover_readonly = fields.Boolean(compute="_compute_cover_readonly", store=False)

    def _is_layout_cover_required(self):
        return self.external_report_layout_id in {
            self.env.ref(f'web.external_layout_{layout}')
            for layout in ('boxed', 'bold', 'striped')
        }

    @api.onchange('external_report_layout_id')
    def _onchange_layout(self):
        for record in self:
            if self._is_layout_cover_required():
                self.company_id.snailmail_cover = True

    @api.depends('external_report_layout_id')
    def _compute_cover_readonly(self):
        for record in self:
            record.snailmail_cover_readonly = self._is_layout_cover_required()