El 31/01/16 a las 14:15, Cédric Krier escribió:
On 2016-01-31 09:33, Oscar Alvarez wrote:

El 30/01/16 a las 18:08, Cédric Krier escribió:
On 2016-01-30 12:51, Oscar Andres Alvarez Montero wrote:
Hi, devs
I am working 3.6, but de om a new module I need overload get_context from
trytond core, not for a simple report, else for all reports, without create
new Class as CompanyReport, it this possible?
We don't have a way to extend base classes. For now, you have to extend
every report you need or you could try to ugly way by monkey-patching
the Report class.

But maybe there is a better way to achieve your goal if you could give
more detail on the needs.

I am starting the develop of new module [1] for Management System (ISO) [2],
for now is only little module, but a of first model is related with
Documents and Records formats, for example purchase report on quality
systems is a controlled record, so this need the following values on head
document: code, version of document, approved by (person), etc, of course
this values change between documents/records formats, and could be many
formats, the idea is to define this values on a unique model without to call
each model report and overload get_context, just using a field M2O, in this
model:
something like as:

https://bitbucket.org/presik/trytonpsk_ims/src/679891616c125f013d13db965b8d20a23f5c1d19/document_record.py?fileviewer=file-view-default

next, overload Class Report, that add new values to report context if data
of DocumentReport if on context.

     @classmethod
     def get_context(cls, records, data):
         report_context = super(Report, cls).get_context(records, data)
         ims_report = cls._get_report_ims_data()
         report_context['ims_name'] = ims_report.ims_name
         report_context['code'] = ims_report.code
         report_context['version'] = ims_report.version
         report_context['approved_date'] = ims_report.approved_date
         return report_context
I personally don't understand what you try to achieve. I don't know what
you call "purchase report", I don't see the link between your
requirements and the reports. I don't understand why you define a
"unique model".
I want extending ActionReport with three fields to ir.action.report ("code or number", "revision/version", "approved/release date"), and see them printed on reports, (sale order, purchase order, etc, see attached), it print these fields on reports are necessary for all companies that has quality management systems [1][2], because they are important controlled documents/records, not anything else document, and for example "revision" field change constantly, so thats why is better change "revision" value from a record on model, and not set as a constant in a format report.

Another way is not add these fields to ir.action.report, but a new model that as this:

class DocumentRecord(Workflow, ModelSQL, ModelView):
    'Document Record'
    __name__ = 'ims.document_record'
    _rec_name = 'name'
    name = fields.Char('Name', select=True, required=True)
    code = fields.Char('Code', states=STATES, select=True)
    revision = fields.Char('Revision states=STATES, select=True)
approved_date = fields.Char('Approved Date', states=STATES, select=True) report = fields.Many2One('ir.action.report', 'Report') # with this field we link to report


[1] http://mireauxms.com/wp-content/uploads/2014/01/accessible-new.jpg
[2] http://www.versesolutions.com/images/screenshots/documentcontrol.jpg

But in both cases the main problem is that ir.action.report model is not on context of report, maybe a patch like as solve the problem.

    @classmethod
    def get_context(cls, records, data, action_report):
        pool = Pool()
        User = pool.get('res.user')

        report_context = {}
        report_context['data'] = data
        report_context['context'] = Transaction().context
        report_context['user'] = User(Transaction().user)
        report_context['records'] = records
        report_context['format_date'] = cls.format_date
        report_context['format_currency'] = cls.format_currency
        report_context['format_number'] = cls.format_number
        report_context['datetime'] = datetime
        report_context['action_report'] = action_report

        return report_context

Often I find that when people talk about management system, they often
I talking about Quality Management Systems ISO 9000
think about tool but for me, it is much more about company internal
process (I would call it "company culture").


--
You received this message because you are subscribed to the Google Groups 
"tryton-dev" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton-dev/56AED9DF.4020009%40gmail.com.

Attachment: purchase.odt
Description: application/vnd.oasis.opendocument.text

Reply via email to