[tryton-dev] Un-assigned Tryton issue tracker requests

2017-12-30 Thread Tryton issue tracker
Created ID   Activity   Title
===
 bug
3 days ago  7035 3 days ago OS X Client 4.6.1 Crash   
 bug
1 week ago  7026 1 week ago Unable to inactivate reports from user ...
 bug
1 month ago 6970 1 month ago getting sometimes "ERROR: 'NoneType' o ...
 bug
27 months ago 5030 1 month ago Error connecting with Tryton client fr ...
 bug
5 months ago 6672 2 months ago Unable to update product cost_price   
 bug
8 months ago 6470 8 months ago Old migration to rename packing to shi ...
 bug
15 months ago 5905 15 months ago Display bug in tryton client with ubun ...
 bug
34 months ago 4582 34 months ago Display datetime before epoch on windows  
 bug
37 months ago 4359 37 months ago Windows client error when image size i ...

To view or respond to any of the requests listed above, visit the URL

   https://bugs.tryton.org/

and click on "Show Unassigned". Do NOT respond to this message.

-- 
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/20171230230003.75A4D11801A8%40moretus.b2ck.com.


[tryton-dev] Extending python-sql

2017-12-30 Thread 'Udo Spallek' via tryton-dev
Hi,

I would like to extend account_invoice.Invoice.search_total_amount[A]
which is based on a python-sql query.
It should be extended with another module.
In my extension I would like to replace the following column[B]::

Coalesce(Sum(Round(
(
line.quantity * line.unit_price).cast(type_name),
  currency.digits)), 0).as_('total_amount'), 

with something like this::

Coalesce(Sum(Round(
(
line.quantity * line.unit_price * (1 - line.discount /
100.0) ).cast(type_name), currency.digits)), 0).as_('total_amount')


The general boilerplate code in the other module looks like::

class Invoice:
__metaclass__ = PoolMeta
__name__ = 'account.invoice'

@classmethod
def search_total_amount(cls, name, clause):

result = super(Invoice, cls).search_total_amount(
name, clause)


With introspection I found the column::

columns = list(
result[0][2].columns[0].table.select.im_self
.queries[0].columns)

But I have no idea, how to replace the column, because I have not the
correct line object from the depends module.
When I try something like this::

pool = Pool()
Line = pool.get('account.invoice.line')
line = Line.__table__()

columns[1] = Coalesce(Sum(Round((
line.quantity * line.unit_price * (1 - line.discount / 100.0)
).cast(type_name), currency.digits)), 0).as_('total_amount')

result[0][2].columns[0].table.select.im_self.queries[0].columns = \
tuple(columns)

the line table is wrong, I need the table from [B].

Questions:
1. Is it a good practice trying to extend python-sql?
2. Is there a better way to introspect the python-sql then this::

columns = list(
result[0][2].columns[0].table.select.im_self
.queries[0].columns)
3. How to get the line-object from the base sql?

TIA and Regards Udo Spallek

[A]http://hg.tryton.org/modules/account_invoice/file/tip/invoice.py#l741
[B]
http://hg.tryton.org/modules/account_invoice/file/tip/invoice.py#l764

-- 
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/20171230150819.645b27b7%40bender.fritz.box.


pgpYsbFljkH3x.pgp
Description: Digitale Signatur von OpenPGP