Help with proteus script

i am trying to post an invoice of a sale.

what i succeed, reading and trying

from proteus import config, Model, Wizard, Report
my_config = config.set_trytond('postgresql:///tryton',config_file='/etc/tryton/trytond.conf')
Sale= Model.get('sale.sale')
Invoice= Model.get('account.invoice')
Sale.confirm([2052],Sale._config.context)
sale=Sale(2052)

i can find the invoice (i found dir() ) and with print(sale.invoices)

[proteus.Model.get(‘account.invoice’)(27)]

but i am not able to post the invoice, i tried a lot of things

Invoice(sale.invoices).post();
invoice,=Invoice(sale.invoices)
Invoice.post(sale.get('account.invoice'),Invoice._config.context)

where can i find something that can help me ?

thanks

I found

print(sale.invoices[0].id)

Invoice.post([sale.invoices[0].id],Invoice._config.context) works

how can i pass argument if i want to pay it. I guess that it is in the context but i have always

raise TypeError("context must be a dictionary")
TypeError: context must be a dictionary

With proteus you should not call directly any methods but you should use the .click() which simulate the same action as the user could do on the UI.

i did not choose to do such thing, i did what i saw and what i understood and what i succeed in doing something working.

the documentation here https://downloads-cdn.tryton.org/TUB2013/proteus.pdf is for 10 yo kids - and here Tryton Scripting Client — proteus 6.0 documentation can not be called documentation but… P.O.S - the .clik() is documented nowhere and there is nothing else.
and icing the cake https://hg.tryton.org/tryton-tools/file/tip/tryton_demo.py is 404 (and does not exist on waybackmachine) and of course i did not find anywhere a line of code explaining to get a valid piece of code working.

when i said that it would be a good idea to have some “snippets” of working code, here, https://discuss.tryton.org/t/documentation-for-developers-once-again i was told : read the code.

you, developers, think that things are evidence but they are not. friends of my friend-client choose dolibarr to develop the same thing… it is a shame because dolibarr is much more verbose to do the same things… but i swear that i have the impression that tryton’s developers would be more happy if i have chosen another framework and that they could continue there day-to-day life. They could release the 7.x new version without ******* question.

here https://downloads-cdn.tryton.org/TUB2013/proteus.pdf you must guess what is config.context (a simple line explicating seems not to be an option) and of course in that “documentation”

config = config.set_trytond(config_file=’foo.cfg’,
... user=’admin’, password=’admin’)

is not a valid working code, else things would be too easy

there is nowhere a piece of code complete and working as is_
here Tryton Scripting Client — proteus 6.8 documentation, if you have a local posgres F*ck Off -
here is Importing data on Tryton using proteus - Tryton Academy is just give me 325 € to have some hints

i can register a new party here :

Party = Model.get('party.party')
party = Party()
party.id < 0
*True*

*Fill the fields:*
party.name = 'ham'
*Save the instance into the server:*
party.save()
party.name
*'ham'*

no fucking .click() in the tryton6.8 documentation

would it be so hard to have a simple page with

  1. creating a client
  2. creating an address
  3. creating a sale
  4. validating it with the invoice and shipment
  5. paying the invoice
  6. validating the shipment

this walk-through would cover almost all cases and would permit to someone who would like to work to have some hook to start, diving into the code for more precise thing.

tryton is really a good piece of framework but you must loose days because there is not a simple paragraphs explaining simple operations. and i do think it is a no-go for lots of people. Of course documentation is the more annoying things to do, and when someone says it would be a good idea to dive into doing it, someone tells him that it is better to read the code.
If he stays with tryton (and i guess that many runs away), he keeps what he finds for him. and those 6 steps above are still no addressed 15 years after the first release.

I have lots of idea, i understood that i must keep them for me and not annoying people with them. so i decided to implement them on my own for my client-friend and no bother others with them. and i am really sure that some, installs (if they succeed) tryton, tries, sees how difficult is just to find how and where to register a french or european VAT code for the company or the company’s customers, they fly away. but it would be so simple to name the identifiers with country - name of the identifier (it is not a suggestion, nor something to push into tryton, i do not care : i will change the translation for my friend-client for him to find easily the identifiers type he is looking for.) i am pretty sure that developers do not use this because it is a pain in the ass to find something and any normal human being would have change that 3 times after being forced to use it.

so i guess it would be better to use .click() but there is nowhere in the internet a place where you can find how it is working and how it should be done. and, like with odoo, it seems that keeping things complicated is a way of earning a living for some people. And lots of operations par more complicated that just click() and you are suppose to guess by luck and retries.

i read here openerp2tryton: log not a fucking line of comments to explain what is doing what and where and how.

i will continue to test, dive, find… and i am really sure i did the good choice, but i would not recommend to others.

indeed,

  • tryton project has moved
  • this file has been split in separate actions to help people like you and me.

Is this what you are asking for ?

of course that helps a lot…if you know where to find it…

but i was thinking much more of someting like that

from proteus import config, Model, Wizard, Report

my_config = config.set_trytond('postgresql:///tryton',config_file='/etc/tryton/trytond.conf')
                  ^^^^^^^^^^^^ tryton is the database name ^^^^^^^^^^^
#####  the models you need #
Sale= Model.get('sale.sale')
PaymentMethod = Model.get('account.invoice.payment.method')

##### let's confirm the sale #####
sale=Sale(2057)  #  <<  number of the sale
sale.click('quote') # 
sale.click('confirm') # << you __must__ quote before confirm
# now an invoice and a shipment is create #

# let's post the invoice done from the sale
[inv.click('post') for inv in sale.invoices]

# let's do the shipment
[ship.click('assign_force') for ship in sale.shipments] # you want to bypass the vérifications
[ship.click('pick') for ship in sale.shipments]
[ship.click('pack') for ship in sale.shipments]
[ship.click('done') for ship in sale.shipments # << you need (???) to  get all theses steps

# now le'ts pay the invoice
for inv in sale.invoices :
    with my_config.set_context(active_id=inv.id):
        pay_invoice = Wizard("account.invoice.pay", context=my_config.context, models=[inv])
        pay_invoice.form.date = inv.invoice_date
        pay_invoice.form.description = 'Paiment invoice '+inv.number
        pay_invoice.form.payment_method = PaymentMethod.find([('name', '=', 'cheque')], limit=1)[0] # << 'cheque' is the name of the paiement method i choose.
        pay_invoice.execute('choice')  # << all is done.

i get the help of this post

i get the suggestion of @ced about using .click() and i find here
openerp2tryton: d646f462dc07 (line 97) how to use that.

i am not satisfied with PaymentMethod.find([(‘name’, ‘=’, ‘cheque’)], limit=1)[0] but it works…

maybe that it is too “specific” to be of some utility for some, but i do think that it could help some people.

good news is that it is now embedded and versioned by branches.

I think that you do not understand.

If you are used to play with git and versioning and tryton-core dev and you find an URI in the online doc, easily accessible of course it is good.

BUT if you just want to use it and develop some “small” modules (for example to add base price and discount on invoice) you are not probably used to git and versioning, (and probably not with python) and you search the web for help.

you find the forum and there are a lot of good help. but in my case, i ask for help when ALL i tried did not give me success (at least 1 day trying) and the thing you find easzly is

for user : Tryton Documentation — Tryton Documentation
for making modules : Modules — Tryton server (from my point of view, almost perfect)
for proteus Tryton Scripting Client — proteus 6.8 documentation (a real scandal)

and where you find the doc in your link ? when you give the link after, 2-3 month of difficulties asking a place to find code that would help.

I think that it would be a good think to have it somewhere in top of the documentation.

what i wrote for sale,invoice,shipment, payment is, in my opinion a must have to understand proteus in every day life.

Now i know i can go further and just ask when i hit a wall. now this code is accessible… it is ok for me.

Just trying to help. I hope I did.

You will get more and better answers, depending how you ask.

une mise en abîme parfaite de ce que je veux démontrer.

ne répondez pas cela ne sert à rien.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.