mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[16.0][ADD] printing_simple_configuration
This commit is contained in:
3
printing_simple_configuration/models/__init__.py
Normal file
3
printing_simple_configuration/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from . import company
|
||||
from . import printer
|
||||
from . import print_config
|
||||
7
printing_simple_configuration/models/company.py
Normal file
7
printing_simple_configuration/models/company.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
_inherit = "res.company"
|
||||
|
||||
print_config_id = fields.Many2one(comodel_name="print.config")
|
||||
30
printing_simple_configuration/models/print_config.py
Normal file
30
printing_simple_configuration/models/print_config.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class PrintConfig(models.Model):
|
||||
_name = "print.config"
|
||||
_inherit = ["mail.thread"]
|
||||
_description = "Simple Printing Configuration"
|
||||
_rec_names_search = ["server", "company_id"]
|
||||
_check_company_auto = True
|
||||
|
||||
server = fields.Char(
|
||||
string="🖥 Server",
|
||||
required=True,
|
||||
tracking=True,
|
||||
help="IP or name resolved by your internal DNS",
|
||||
)
|
||||
port = fields.Integer(tracking=True)
|
||||
company_id = fields.Many2one(comodel_name="res.company", string="Company")
|
||||
display_name = fields.Char("Name", compute="_compute_display_name", store=True)
|
||||
comment = fields.Char()
|
||||
printer_ids = fields.One2many(comodel_name="printer", inverse_name="config_id")
|
||||
|
||||
@api.depends("server", "company_id")
|
||||
def _compute_display_name(self):
|
||||
for rec in self:
|
||||
company = rec.company_id
|
||||
if company:
|
||||
rec.display_name = "{} ({})".format(rec.server, company.name)
|
||||
else:
|
||||
rec.display_name = rec.server
|
||||
21
printing_simple_configuration/models/printer.py
Normal file
21
printing_simple_configuration/models/printer.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class Printer(models.Model):
|
||||
_name = "printer"
|
||||
_description = "Printers belongs to a printer server address attached "
|
||||
"to a company or a warehouse"
|
||||
|
||||
name = fields.Char(required=True, help="must be completed by internal user")
|
||||
usage = fields.Char(
|
||||
required=True,
|
||||
help="Developers may use this to guess adapted printers for their workflows",
|
||||
)
|
||||
comment = fields.Char()
|
||||
config_id = fields.Many2one(comodel_name="print.config", required=True)
|
||||
warehouse_id = fields.Many2one(comodel_name="stock.warehouse")
|
||||
readonly = fields.Boolean(
|
||||
help="Make some fields readonly in views if set to True.\n"
|
||||
"In some case, erp project may be imply minimal config as module data\n"
|
||||
"with some fields might updated within the interface"
|
||||
)
|
||||
Reference in New Issue
Block a user