~opencrea/+junk/aprobio

« back to all changes in this revision

Viewing changes to printer_tray/models/printing_report_xml_action.py

  • Committer: joannes
  • Date: 2017-05-17 09:40:42 UTC
  • Revision ID: joannes@debian-20170517094042-47q3j6on72w2h1il
community module

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
# Copyright (C) 2013-2014 Camptocamp (<http://www.camptocamp.com>)
 
3
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
 
4
 
 
5
from odoo import api, fields, models
 
6
 
 
7
 
 
8
class PrintingReportXMLAction(models.Model):
 
9
    _inherit = 'printing.report.xml.action'
 
10
 
 
11
    printer_tray_id = fields.Many2one(
 
12
        comodel_name='printing.tray',
 
13
        string='Paper Source',
 
14
        domain="[('printer_id', '=', printer_id)]",
 
15
    )
 
16
 
 
17
    @api.multi
 
18
    def behaviour(self):
 
19
        self.ensure_one()
 
20
        res = super(PrintingReportXMLAction, self).behaviour()
 
21
        res['tray'] = self.printer_tray_id.system_name
 
22
        return res
 
23
 
 
24
    @api.onchange('printer_id')
 
25
    def onchange_printer_id(self):
 
26
        """ Reset the tray when the printer is changed """
 
27
        self.printer_tray_id = False