mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[FIX] printing_simple_configuration: add company_id to printer
[FIX] printing_simple_configuration: add _get_printer_by_usage [FIX] printing_simple_configuration: dependency [FIX] printing_simple_configuration: maintainers
This commit is contained in:
@@ -5,13 +5,13 @@
|
|||||||
"category": "Generic Modules/Base",
|
"category": "Generic Modules/Base",
|
||||||
"website": "https://github.com/OCA/report-print-send",
|
"website": "https://github.com/OCA/report-print-send",
|
||||||
"author": "Akretion,Odoo Community Association (OCA)",
|
"author": "Akretion,Odoo Community Association (OCA)",
|
||||||
"maintainer": [
|
"maintainers": [
|
||||||
"bealdav",
|
"bealdav",
|
||||||
],
|
],
|
||||||
"maturity": "Alpha",
|
"maturity": "Alpha",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"depends": [
|
"depends": [
|
||||||
"stock",
|
"sale_stock",
|
||||||
],
|
],
|
||||||
"data": [
|
"data": [
|
||||||
"views/company.xml",
|
"views/company.xml",
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
from odoo import fields, models
|
import logging
|
||||||
|
|
||||||
|
from odoo import _, api, fields, models
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Printer(models.Model):
|
class Printer(models.Model):
|
||||||
@@ -19,3 +24,34 @@ class Printer(models.Model):
|
|||||||
"In some case, erp project may be imply minimal config as module data\n"
|
"In some case, erp project may be imply minimal config as module data\n"
|
||||||
"with some fields might updated within the interface"
|
"with some fields might updated within the interface"
|
||||||
)
|
)
|
||||||
|
company_id = fields.Many2one(
|
||||||
|
"res.company",
|
||||||
|
related="config_id.company_id",
|
||||||
|
store=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _get_printer_by_usage(self):
|
||||||
|
printers = {}
|
||||||
|
company = self.env.company
|
||||||
|
|
||||||
|
domain = [("company_id", "=", company.id)]
|
||||||
|
if self.env.user.property_warehouse_id:
|
||||||
|
domain.append(("warehouse_id", "=", self.env.user.property_warehouse_id.id))
|
||||||
|
else:
|
||||||
|
domain.append(("warehouse_id", "=", False))
|
||||||
|
|
||||||
|
for device in self.search(domain, order="warehouse_id DESC, usage, name DESC"):
|
||||||
|
conf = device.sudo().config_id
|
||||||
|
printers[device.usage] = {
|
||||||
|
"location": "https://%s:%s" % (conf.server, conf.port or 0),
|
||||||
|
"name": device.name,
|
||||||
|
"comment": device.comment,
|
||||||
|
}
|
||||||
|
_logger.info(" >>> Printers %s" % printers)
|
||||||
|
if not printers:
|
||||||
|
raise UserError(
|
||||||
|
_("There is no printer accessible to you in the company %s")
|
||||||
|
% company.name
|
||||||
|
)
|
||||||
|
return printers
|
||||||
|
|||||||
Reference in New Issue
Block a user