Re: [tryton] dont show stack trace on exceptions
On Monday, July 6, 2015 at 6:40:06 PM UTC-3, Cédric Krier wrote: On 2015-07-06 12:27, Mariano Ramon wrote: is there anyway to customize runtime errors that show the python exception and use a catch all with a more user friendly message? By definition a traceback is an exception that is not expected. Hiding it will just result of never fixing the problem, so that's why Tryton shows such unexpected error. If you want a friendly message, you must write code that doesn't crash unexpectly. Of course, it was not intended as a solution. I asked because frameworks usually have a debug mode that works like it does now and the prodution mode where internals are not leaked in case of a bug. Mariano
[tryton] dont show stack trace on exceptions
is there anyway to customize runtime errors that show the python exception and use a catch all with a more user friendly message?
Re: [tryton] modify client search behavior
On Friday, June 19, 2015 at 4:30:03 AM UTC-3, Cédric Krier wrote: On 2015-06-18 13:09, Mariano Ramon wrote: Don't know which version you are using but it is already implemented by https://bugs.tryton.org/issue4006 I have 3.2.2, not possible to change at the moment, but I applied the changes manually and worked like charm (Thanks!) except for the many2many that are implemented using opposites one2many. how can I forward the search term for it to appear in the new search windows? Is those cases that when you click a new empty records appears ready to edit without using a form view I don't understand the patch also change the Many2Many widget. extracted verbatim from the gnuhealth libraries: when implemented like this when you add a new specialty it appears directly on the embedded list of related entities, where you can search for existing ones in a similar fashion (shows the list, plus Search and Create) But clicking in search doesn't include the term on the new window. class HealthInstitutionO2M(ModelSQL, ModelView): 'Health Institution' __name__ = 'gnuhealth.institution' # Add Specialties to the Health Institution specialties = fields.One2Many('gnuhealth.institution.specialties', 'name','Specialties', help=Specialties Provided in this Health Institution) main_specialty = fields.Many2One('gnuhealth.institution.specialties', 'Specialty', domain=[('name', '=', Eval('active_id'))], depends=['specialties'], help=Choose the speciality in the case of Specialized Hospitals \ or where this center excels, states={'required': And(Eval('institution_type') == 'specialized', Bool(Eval('specialties'))), 'readonly': Not(Bool(Eval('name')))}) # Add Specialties to the Health Institution operational_sectors = fields.One2Many('gnuhealth.institution.operationalsector', 'name','Operational Sector', help=Operational Sectors covered by this institution) class HealthInstitutionSpecialties(ModelSQL, ModelView): 'Health Institution Specialties' __name__ = 'gnuhealth.institution.specialties' name = fields.Many2One('gnuhealth.institution', 'Institution') specialty = fields.Many2One('gnuhealth.specialty', 'Specialty') def get_rec_name(self, name): if self.name: return self.specialty.name class MedicalSpecialty(ModelSQL, ModelView): 'Medical Specialty' __name__ = 'gnuhealth.specialty' name = fields.Char( 'Specialty', required=True, translate=True, help='ie, Addiction Psychiatry') code = fields.Char('Code', required=True, help='ie, ADP. Please use CAPITAL LETTERS and no spaces') @classmethod def __setup__(cls): cls._sql_constraints = [ ('name_uniq', 'UNIQUE(name)', 'The Specialty must be unique !'), ('code_uniq', 'UNIQUE(code)', 'The CODE must be unique !'), ] super(MedicalSpecialty, cls).__setup__()
Re: [tryton] modify client search behavior
Don't know which version you are using but it is already implemented by https://bugs.tryton.org/issue4006 I have 3.2.2, not possible to change at the moment, but I applied the changes manually and worked like charm (Thanks!) except for the many2many that are implemented using opposites one2many. how can I forward the search term for it to appear in the new search windows? Is those cases that when you click a new empty records appears ready to edit without using a form view. Default search like this one is mapped to the rec_name field. You can either set it to an existing field : class MyModel(...): _rec_name = 'name' Will map the rec_name field to the 'name' field, so any search on rec_name will be the same than a search on name. For something more complicated, you can override search_rec_name to do the search the way you like. if I need to search using more than one column I have no choice but to use search_rec_name method, do I? Thanks again you've been really helpful Mariano
[tryton] what is the proper way of filling the (empty) list of vat countries from a custom module?
I can see that that list is hardcoded in the party.py file and starts empty. and is a list defined outside any class, how do I get to that scope from a module to overwrite it? or better yet is there any better way to modify that list than directly in the code? why starts empty? Thanks
[tryton] create Many2One field with just a subset of records dinamically
Hello, good afternoon everyone I have two many2one field defined with default options like this. In a model profesional = fields.Many2One('gnuhealth.healthprofessional', 'Profesional', required=True) especialidad = fields.Many2One('gnuhealth.specialty','Especialidad', help='Especialidad') both profesional and specialidad are related. But the posible options of especialidad depends on what's set on profesional. Is there any way to dinamically select which of all the especialidad records can be found when searching? is this possible to do before saving? Thanks. Mariano
Re: [tryton] Re: remove Ust from party
Yes, you can add a states on the fields which will make it invisible when user is in a specific group. I have question regarding this... how would I set a state for something that is not a field. more precisely a group view element? or should I set the state for each indivual element (some of them are not fields but functions). And if this is the case, how do I avoid the empty frame? should I write the pyson statement directly on the xml? how do I reference view elements from the module? Thanks. -- Cédric Krier B2CK SPRL Rue de Rotterdam, 4 4000 Liège Belgium Tel: +32 472 54 46 59 Email: cedric...@b2ck.com javascript: Jabber: cedric...@b2ck.com javascript: Website: http://www.b2ck.com/
Re: [tryton] create related record programatically.
On Friday, January 9, 2015 at 9:50:03 PM UTC-3, Cédric Krier wrote: On 09 Jan 12:02, Mariano Ramon wrote: I'm now having trouble doing stuff when it updates the record. I tried extending the methods write and save, but none are doing anything. if i use this when creating records: class CustomParty(ModelSQL, ModelView): 'Party' __name__ = 'party.party' @classmethod def create(cls, vlist): records = super(CustomParty, cls).create(vlist) what should I use for when updating? and when deleting? It is the methods: write, delete I had defined somewhere else in the code and that is what wasn't doing anything http://doc.tryton.org/3.4/trytond/doc/ref/models/models.html#trytond.model.ModelStorage.write http://doc.tryton.org/3.4/trytond/doc/ref/models/models.html#trytond.model.ModelStorage.delete PS: Please don't top-post on this mailing list, see http://groups.tryton.org/netiquette Sorry, I did it because was following the same issue and a similar question, but was not following anything said, I'll just put it at the bottom next time Have a great day. Mariano -- Cédric Krier - B2CK SPRL Email/Jabber: cedric...@b2ck.com javascript: Tel: +32 472 54 46 59 Website: http://www.b2ck.com/
Re: [tryton] create related record programatically.
I'm now having trouble doing stuff when it updates the record. I tried extending the methods write and save, but none are doing anything. if i use this when creating records: class CustomParty(ModelSQL, ModelView): 'Party' __name__ = 'party.party' @classmethod def create(cls, vlist): records = super(CustomParty, cls).create(vlist) what should I use for when updating? and when deleting? Thanks On Thursday, January 8, 2015 at 2:36:54 PM UTC-3, Mariano Ramon wrote: Oh Yeah! I did that before and don't know why I changed it! Thanks so much for taking the time to go through my code. It worked Mariano. On Thursday, January 8, 2015 12:52:52 PM UTC-3, jmartin wrote: 2015-01-08 15:10 GMT+01:00 Mariano Ramon mariano...@gmail.com: Ok this got a bit long so I summarize and I added the corrections that were made along the way: 1) I have two classes Party and Patient 2) The only constraint to create a Patient is to have a related Party 3)I need to create a Patient when a Party is created and set the relation between the two (Actually when updating and deleting too and it has to work both ways but I'm focusing just on this for now) here are the two classes: class Patient(ModelSQL, ModelView): __name__ = 'gnuhealth.patient' name = fields.Many2One( 'party.party', 'Patient', required=True, domain=[ ('is_patient', '=', True), ('is_person', '=', True), ], states={'readonly': Bool(Eval('name'))}, help=Person associated to this patient) class Party(ModelSQL, ModelView): 'Party' __name__ = 'party.party' @classmethod def create(cls, vlist): records = super(Party, cls).create(vlist) pool = Pool() Patient = pool.get('gnuhealth.patient') patient = Patient() patient.name = records You are assigning a list of instances of parties to M2O record instead of a party instance. Try to select the first one. patient.save() return records when I try to create a party I get: Traceback (most recent call last): File /gnuhealth/tryton/server/trytond-3.2.4/trytond/protocols/dispatcher.py, line 158, in dispatch result = rpc.result(meth(*c_args, **c_kwargs)) File /gnuhealth/tryton/server/trytond-3.2.4/trytond/modules/custom/custom.py, line 283, in create patient.name = records File /gnuhealth/tryton/server/trytond-3.2.4/trytond/model/model.py, line 445, in __setattr__ super(Model, self).__setattr__(name, value) File /gnuhealth/tryton/server/trytond-3.2.4/trytond/model/fields/many2one.py, line 80, in __set__ assert isinstance(value, (Target, NoneType)) AssertionError a representation of records which would be value in the last line of the stack trace gives me: [Pool().get('party.party')(17809)] other thing I tried is not saving Patient and appending it to records: @classmethod def create(cls, vlist): records = super(CustomParty, cls).create(vlist) pool = Pool() Patient = pool.get('gnuhealth.patient') patient = Patient() records.append(patient) return records which gives me: Traceback (most recent call last): File gnuhealth/tryton/server/trytond-3.2.4/trytond/protocols/dispatcher.py, line 158, in dispatch result = rpc.result(meth(*c_args, **c_kwargs)) File gnuhealth/tryton/server/trytond-3.2.4/trytond/model/modelstorage.py, line 51, in lambda result=lambda r: map(int, r)), File gnuhealth/tryton/server/trytond-3.2.4/trytond/model/model.py, line 456, in __int__ return int(self.id) TypeError: int() argument must be a string or a number, not 'NoneType' Regards Mariano -- Jesús Martín Zikzakmedia SL C/ de Sant Jaume, 9, baixos, 2ª 08720 Vilafranca del Penedès ☏ 93 890 21 08
Re: [tryton] create related record programatically.
Oh Yeah! I did that before and don't know why I changed it! Thanks so much for taking the time to go through my code. It worked Mariano. On Thursday, January 8, 2015 12:52:52 PM UTC-3, jmartin wrote: 2015-01-08 15:10 GMT+01:00 Mariano Ramon mariano...@gmail.com javascript:: Ok this got a bit long so I summarize and I added the corrections that were made along the way: 1) I have two classes Party and Patient 2) The only constraint to create a Patient is to have a related Party 3)I need to create a Patient when a Party is created and set the relation between the two (Actually when updating and deleting too and it has to work both ways but I'm focusing just on this for now) here are the two classes: class Patient(ModelSQL, ModelView): __name__ = 'gnuhealth.patient' name = fields.Many2One( 'party.party', 'Patient', required=True, domain=[ ('is_patient', '=', True), ('is_person', '=', True), ], states={'readonly': Bool(Eval('name'))}, help=Person associated to this patient) class Party(ModelSQL, ModelView): 'Party' __name__ = 'party.party' @classmethod def create(cls, vlist): records = super(Party, cls).create(vlist) pool = Pool() Patient = pool.get('gnuhealth.patient') patient = Patient() patient.name = records You are assigning a list of instances of parties to M2O record instead of a party instance. Try to select the first one. patient.save() return records when I try to create a party I get: Traceback (most recent call last): File /gnuhealth/tryton/server/trytond-3.2.4/trytond/protocols/dispatcher.py, line 158, in dispatch result = rpc.result(meth(*c_args, **c_kwargs)) File /gnuhealth/tryton/server/trytond-3.2.4/trytond/modules/custom/custom.py, line 283, in create patient.name = records File /gnuhealth/tryton/server/trytond-3.2.4/trytond/model/model.py, line 445, in __setattr__ super(Model, self).__setattr__(name, value) File /gnuhealth/tryton/server/trytond-3.2.4/trytond/model/fields/many2one.py, line 80, in __set__ assert isinstance(value, (Target, NoneType)) AssertionError a representation of records which would be value in the last line of the stack trace gives me: [Pool().get('party.party')(17809)] other thing I tried is not saving Patient and appending it to records: @classmethod def create(cls, vlist): records = super(CustomParty, cls).create(vlist) pool = Pool() Patient = pool.get('gnuhealth.patient') patient = Patient() records.append(patient) return records which gives me: Traceback (most recent call last): File gnuhealth/tryton/server/trytond-3.2.4/trytond/protocols/dispatcher.py, line 158, in dispatch result = rpc.result(meth(*c_args, **c_kwargs)) File gnuhealth/tryton/server/trytond-3.2.4/trytond/model/modelstorage.py, line 51, in lambda result=lambda r: map(int, r)), File gnuhealth/tryton/server/trytond-3.2.4/trytond/model/model.py, line 456, in __int__ return int(self.id) TypeError: int() argument must be a string or a number, not 'NoneType' Regards Mariano -- Jesús Martín Zikzakmedia SL C/ de Sant Jaume, 9, baixos, 2ª 08720 Vilafranca del Penedès ☏ 93 890 21 08
Re: [tryton] create related record programatically.
Ok this got a bit long so I summarize and I added the corrections that were made along the way: 1) I have two classes Party and Patient 2) The only constraint to create a Patient is to have a related Party 3)I need to create a Patient when a Party is created and set the relation between the two (Actually when updating and deleting too and it has to work both ways but I'm focusing just on this for now) here are the two classes: class Patient(ModelSQL, ModelView): __name__ = 'gnuhealth.patient' name = fields.Many2One( 'party.party', 'Patient', required=True, domain=[ ('is_patient', '=', True), ('is_person', '=', True), ], states={'readonly': Bool(Eval('name'))}, help=Person associated to this patient) class Party(ModelSQL, ModelView): 'Party' __name__ = 'party.party' @classmethod def create(cls, vlist): records = super(Party, cls).create(vlist) pool = Pool() Patient = pool.get('gnuhealth.patient') patient = Patient() patient.name = records patient.save() return records when I try to create a party I get: Traceback (most recent call last): File /gnuhealth/tryton/server/trytond-3.2.4/trytond/protocols/dispatcher.py, line 158, in dispatch result = rpc.result(meth(*c_args, **c_kwargs)) File /gnuhealth/tryton/server/trytond-3.2.4/trytond/modules/custom/custom.py, line 283, in create patient.name = records File /gnuhealth/tryton/server/trytond-3.2.4/trytond/model/model.py, line 445, in __setattr__ super(Model, self).__setattr__(name, value) File /gnuhealth/tryton/server/trytond-3.2.4/trytond/model/fields/many2one.py, line 80, in __set__ assert isinstance(value, (Target, NoneType)) AssertionError a representation of records which would be value in the last line of the stack trace gives me: [Pool().get('party.party')(17809)] other thing I tried is not saving Patient and appending it to records: @classmethod def create(cls, vlist): records = super(CustomParty, cls).create(vlist) pool = Pool() Patient = pool.get('gnuhealth.patient') patient = Patient() records.append(patient) return records which gives me: Traceback (most recent call last): File gnuhealth/tryton/server/trytond-3.2.4/trytond/protocols/dispatcher.py, line 158, in dispatch result = rpc.result(meth(*c_args, **c_kwargs)) File gnuhealth/tryton/server/trytond-3.2.4/trytond/model/modelstorage.py, line 51, in lambda result=lambda r: map(int, r)), File gnuhealth/tryton/server/trytond-3.2.4/trytond/model/model.py, line 456, in __int__ return int(self.id) TypeError: int() argument must be a string or a number, not 'NoneType' Regards Mariano
Re: [tryton] create related record programatically.
On Tuesday, January 6, 2015 5:05:04 AM UTC-3, Cédric Krier wrote: On 05 Jan 21:58, Sergi Almacellas Abellana wrote: On 5 de gener de 2015 21:18:45 CET, Mariano Ramon mariano...@gmail.com javascript: wrote: Which is the function that runs on creations of any model. The create function of a model is called every time you create some records of the model. The signature is the following: def create(cls, vlist) where vlist is a list of dictionaries, where each dictionary a key value for each field of the model. The key is the name of the field, and the value is the value used to create the record. But this method should no more be recommended, the right one is: save() on instance. Actually both answers are useful. I need a record to be saved with default values on the creation of another. Is there any other better way to hook on this event?, and if I have to use create.. how do I it without interfering with the creation of the parent record? And how can I instantiate and assign a different but related model to one of the fields of the first? Don't understand the question. Can you put clarify or put an example? I guess he means putting a value of a Many2One field. record = MyModel() target = MyTarget() target.save() record.target = target record.save() yes this is what I would need to do when updating or creating record would this be correct?: class MyModel(ModelSQL, ModelView): 'MyModel' __name__ = 'mymodel.mymodel' @classmethod def create(cls, vlist): super(MyModel, cls).create(vlist) target = MyTarget() # # set desired values here # target.save() self.target = target self.save() thanks! Mariano
Re: [tryton] create related record programatically.
On Tuesday, January 6, 2015 11:09:09 AM UTC-3, Mariano Ramon wrote: On Tuesday, January 6, 2015 5:05:04 AM UTC-3, Cédric Krier wrote: On 05 Jan 21:58, Sergi Almacellas Abellana wrote: On 5 de gener de 2015 21:18:45 CET, Mariano Ramon mariano...@gmail.com wrote: Which is the function that runs on creations of any model. The create function of a model is called every time you create some records of the model. The signature is the following: def create(cls, vlist) where vlist is a list of dictionaries, where each dictionary a key value for each field of the model. The key is the name of the field, and the value is the value used to create the record. But this method should no more be recommended, the right one is: save() on instance. Actually both answers are useful. I need a record to be saved with default values on the creation of another. Is there any other better way to hook on this event?, and if I have to use create.. how do I it without interfering with the creation of the parent record? And how can I instantiate and assign a different but related model to one of the fields of the first? Don't understand the question. Can you put clarify or put an example? I guess he means putting a value of a Many2One field. record = MyModel() target = MyTarget() target.save() record.target = target record.save() yes this is what I would need to do when updating or creating record would this be correct?: class MyModel(ModelSQL, ModelView): 'MyModel' __name__ = 'mymodel.mymodel' @classmethod def create(cls, vlist): super(MyModel, cls).create(vlist) target = MyTarget() # # set desired values here # target.save() self.target = target self.save() thanks! Mariano CLARIFICATION: here is the actual class: class CustomParty(ModelSQL, ModelView): 'Party' __name__ = 'party.party' @classmethod def create(cls, vlist): records = super(CustomParty, cls).create(vlist) target = CustomPatient() target.name = records[0] target.save() but this gives me assert self.name is not None AssertionError printing records[0] gives me class 'trytond.pool.party.party' the question would be how do I get the instances of the party that was just created? I have the impression that I'm missing some basic python stuff here, even some basic programming concept maybe.. sorry about that.
[tryton] create related record programatically.
Which is the function that runs on creations of any model. And how can I instantiate and assign a different but related model to one of the fields of the first? Happy new year! Mariano
[tryton] creating/modifying widgets
Hello I was looking for info about creating custom widgets, and the only I could find is this link http://www.tryton.org/posts/tryton-unconference-2012.html which says you talked about it in 2011, found the videos of the 2011 conference but you didn't talk about that and then I realized that the URL and the content of that page don't match, so probably that was a 2012 topic. Anyway, do you have any links or transcript where you talk about custom widgets? is there any clean way to modifying existing ones? either through python inheritance, monkey patching or some tryton specific method like the view inheritance? Any info on the subject you can point me to before I delve in the code, would be greatly appreciated and will a huge time saver. Thanks.
Re: [tryton] modules update order
On Monday, November 3, 2014 2:40:04 PM UTC-3, Cédric Krier wrote: On 03 Nov 09:07, Mariano Ramon wrote: Since [1], it is possible to forge a po file that will overide translations. You must just reuse the same line as in original po file but prefix ressource ID by the module name + '.'. [1] http://hg.tryton.org/trytond/rev/62615d5dba33 Could you clarify this with an example. I have something like this: msgctxt model:ir.action,name:act_psc_form1 msgid PSC msgstr LSP and I have a module named custom, should I write: msgctxt model:ir.action,name:.custom.act_psc_form1 msgid PSC msgstr LSP Without the point: msgctxt model:ir.action,name:custom.act_psc_form1 should I add the resource to my module too? in locale/xx_XX.po file I meant if I have to add it to the view file of my own module, like when extending views. I get this error when adding it like this example and updating the module: [Tue Nov 04 13:06:11 2014] INFO:modules:custom:loading locale/es_AR.po Traceback (most recent call last): File ./gnuhealth/xxx/server/trytond-3.2.3/bin/trytond, line 113, in module trytond.server.TrytonServer(options).run() File /home/xxx/gnuhealth/tryton/server/trytond-3.2.3/trytond/server.py, line 123, in run Pool(db_name).init(update=update, lang=lang) File /home/xxx/gnuhealth/tryton/server/trytond-3.2.3/trytond/pool.py, line 151, in init lang=lang) File /home/xxx/gnuhealth/tryton/server/trytond-3.2.3/trytond/modules/__init__.py, line 429, in load_modules _load_modules() File /home/xxx/gnuhealth/tryton/server/trytond-3.2.3/trytond/modules/__init__.py, line 397, in _load_modules load_module_graph(graph, pool, lang) File /home/xxx/gnuhealth/tryton/server/trytond-3.2.3/trytond/modules/__init__.py, line 264, in load_module_graph Translation.translation_import(lang2, module, filename) File /home/xxx/gnuhealth/tryton/server/trytond-3.2.3/trytond/ir/translation.py, line 855, in translation_import override_translation(res_id, translation) File /home/xxx/gnuhealth/tryton/server/trytond-3.2.3/trytond/ir/translation.py, line 813, in override_translation ('fs_id', '=', res_id), ValueError: need more than 0 values to unpack Thanks!. My superiors are talking about donating. Bureaucracy is a fickle mistress and exchange rates to euros are insane here, but we are on it. Have a good day.
Re: [tryton] modules update order
Since [1], it is possible to forge a po file that will overide translations. You must just reuse the same line as in original po file but prefix ressource ID by the module name + '.'. [1] http://hg.tryton.org/trytond/rev/62615d5dba33 Could you clarify this with an example. I have something like this: msgctxt model:ir.action,name:act_psc_form1 msgid PSC msgstr LSP and I have a module named custom, should I write: msgctxt model:ir.action,name:.custom.act_psc_form1 msgid PSC msgstr LSP ? should I add the resource to my module too? thanks.
Re: [tryton] Show data from another entity in the hiearchy
On Wednesday, October 15, 2014 9:29:58 AM UTC-3, Cédric Krier wrote: On 10 Oct 13:32, Mariano Ramon wrote: I apologize in advance for the vagueness of this request but I'm pretty lost. I have these entities FamilyMembers / Patient / Person ( this three are in hiearchy of the Party Entity ) I don't understand. Please disregard, is not relevant to the question. For clarity I only use FamiliyMember from now on. Family (which has FamilyMembers) FamilyGroup (which has many Families) Please provide standard Model definition. class FamilyMember(ModelSQL, ModelView): 'Family Member' __name__ = 'custom.family_member' name = fields.Many2One( 'custom.family', 'Family', required=True, readonly=True, help='Family code') class Family(ModelSQL, ModelView): 'Family' __name__ = 'custom.family' familygroup = fields.Many2One('custom.familygroup', 'FAMILYGROUP') name = fields.Char('Family', required=True, help='Family code') members = fields.One2Many( 'custom.family_member', 'name', 'Family Members') class FamilyGroup(ModelSQL, ModelView): 'Family Group' __name__ = 'custom.familygroup' descripcion = fields.Char('Descripcion del FAMILYGROUP', help='Descripcion del FAMILYGROUP') familias = fields.One2Many('custom.family', 'familygroup', 'Familias', add_remove=[('familygroup', '=', None)]) I removed non related fields and methods I need to show in the FamilyMember view the description field of the FamilyGroup it belongs... only if this familymember belongs to a family and only if this family belongs to a familygroup. Hope this make my request a bit clearer Thanks.
Re: [tryton] Show data from another entity in the hiearchy
Thanks.. this solves many cases where I have to do this. I defined the function field like this in familymember: familygroup = fields.Function( fields.Char('FAMILY GROUP', readonly=True), 'get_familygroup') def familygroup(self, name): return A string yet no matter what the getter returns is always show empty in the view form (both edit and create) any idea what this may be? Another question.. Let's say that familymember has a unidirectional relationship with Party. class FamilyMember(ModelSQL, ModelView): 'Family Member' __name__ = 'custom.family_member' party = fields.Many2One( 'party.party', 'Party', required=True, domain=[('is_person', '=', True)], help='Family Member') and I have to show the same familygroup description in the party view. How do I query familymember (or familygroup directly for that matter) from party? Thanks
[tryton] Show data from another entity in the hiearchy
I apologize in advance for the vagueness of this request but I'm pretty lost. I have these entities FamilyMembers / Patient / Person ( this three are in hiearchy of the Party Entity ) Family (which has FamilyMembers) FamilyGroup (which has many Families) I need to show the family group from the patient.. only if he belongs to a family and only if this family belongs to a group I tried to follow this discussion https://groups.google.com/forum/#!searchin/tryton/$20domain/tryton/yUIevSXB_R8/VJhFdZW2hAsJ but I'm really confused of where to put what. I guess I have to use field.Function in FamilyMember but what type of field should be inside it? Thanks. Mariano
[tryton] modules update order
Is there any way to define in which order the modules are loaded when running ./trytond --update=all?. I would like to keep all modifications of downloaded modules in a separate module. This is ok for redefining fields but then the order matters when replacing translations, and and whichever module is registered last, even if you update just the module you want, others get registered too. And the order is not alphabetical so just naming the module zcustom probably won't work. Thanks. Mariano
Re: [tryton] Re: Defining a many2many relationship issue
Why are you overriding search? I get the error: File ../trytond-3.2.2/trytond/model/fields/one2many.py, line 98, in get targets = list(chain(*targets)) TypeError: 'NoneType' object is not iterable It is the wrong signature for search: http://doc.tryton.org/3.2/trytond/doc/ref/models/models.html?highlight=search#trytond.model.ModelStorage.search Im so sorry. again in one of my edits I must deleted one of TeamDoctor inheritances and was asking the search method.Which wasn't necessary to override at all. I finally solved it adding the Many2Many on the opposite side of the relation. (which in turn I had to change later because I needed extra fields on the linking table which ended like a regular model with its views and all) Again sorry for the confusion. I'll be more careful next time when pasting a different version of my actual code. Thanks for the prompt help, it's greatly appreciated. Mariano
Re: [tryton] modules update order
The order is follow the dependency of the modules and in case of same level, it is the alphabetical order. For your case, your custom module must depend on all the other modules that it extends. This worked when changing fields or labels, but I can't find a way to change menuitems (and the view title in consequence) in a programmatic way, without changing the actual locale files of the module. It also works when editing using the tryton client interface for translations. I tried reinstalling the intervening module to no avail. It would really helpful to know if there's a way to change menuitems translations from a different module, in order to make the deployment process work without intervention. Thanks.
[tryton] Request for advice on how to learn the framework
Hello, my name is Mariano. We are currently developing an integrated system for all laboratories, hospitals and general demographics for a municipality. As a client requirement we are using tryton with gnuhealth modules, overriding and adding what's necessary to fit their specific needs. *So far I managed to create a new module, create new models and the views for it, extending existing views and models. Most of what I learned was by crossing the reference documentation with actual code of some of the modules.* *I have some experience with python and extensive use of MVC frameworks (php mostly),* yet I'm struggling to get consisting results. Finding myself many times just trying things until I get what I need. This makes me highly dependent on finding some working code that does exactly what I need and limits me on using all of the framework features. I must admit that during my years as a programmer I haven't been too keen on learning frameworks just by reading its code and since the tryton documentation is merely referential without examples of cohesive use of the elements this seems to be the only choice. Which is fine but *that's why I ask you, if you have the time, for some guidelines of how interpret the code,* extra documentation you suggest I read to get a better grasp of the framework. Whether is about python, mvc or anything that I might be missing that has direct application to some part of how this framework is built. I'd really like to get well versed on the framework given the broad application it has, and I promise to post my contributions if I get to do something meaningful. Saludos, Mariano.
[tryton] add search for many2one field
how do I enable the search in the view for a many2one field like the one that shows by default in many2many? I have Family and FamilyGroup Family has the many to one field. From the view of this entity I can select which group. FamilyGroup has many families but it just lets me create new families from the view. I Can't choose families I created before and have no group assigned. Thanks. Mariano
[tryton] Defining a many2many relationship issue
I have doctor and team and doctorteam, every doctor can belong to many teams and teams can have many doctors They are defined like this (removed/edited things for brevity/clarity): class Team(ModelSQL, ModelView): 'Etc' __name__ = 'team' doctors = fields.Many2Many('team_doctor', 'team', 'doctor', 'Doctors' ) class TeamDoctor(ModelSQL, ModelView): 'etc' __name__ = 'team_doctor' team = fields.Many2One('team','Team', required=True) doctor = fields.Many2One('doctor', 'Doctor', required=True) def search(cls, name, clause): pass class Doctor(ModelSQL, ModelView): 'etc' __name__ = 'doctor' teams = fields.One2Many('team_doctor', 'doctor', 'TEAMs') this seems to work except when I try to access Doctor from any view I get the error when search is not defined in TeamDoctor AttributeError: type object 'doctor_doctorgroup' has no attribute 'search' I dont know how to define that method search, I always get unbound method search() must be called with doctor_doctorgroup instance as first argument (got list instance instead() no matter what What I'm doing wrong? Thanks! Mariano
[tryton] Re: Defining a many2many relationship issue
On Friday, October 3, 2014 2:41:58 PM UTC-3, Mariano Ramon wrote: I have doctor and team and doctorteam, every doctor can belong to many teams and teams can have many doctors They are defined like this (removed/edited things for brevity/clarity): class Team(ModelSQL, ModelView): 'Etc' __name__ = 'team' doctors = fields.Many2Many('team_doctor', 'team', 'doctor', 'Doctors' ) class TeamDoctor(ModelSQL, ModelView): 'etc' __name__ = 'team_doctor' team = fields.Many2One('team','Team', required=True) doctor = fields.Many2One('doctor', 'Doctor', required=True) def search(cls, name, clause): pass class Doctor(ModelSQL, ModelView): 'etc' __name__ = 'doctor' teams = fields.One2Many('team_doctor', 'doctor', 'TEAMs') this seems to work except when I try to access Doctor from any view I get the error when search is not defined in TeamDoctor AttributeError: type object 'doctor_doctorgroup' has no attribute 'search' Correction: error says AttributeError: type object 'team_doctor' has no attribute 'search' I dont know how to define that method search, I always get unbound method search() must be called with doctor_doctorgroup instance as first argument (got list instance instead() no matter what Correction: error says unbound method search() must be called with team_doctor instance as first argument (got list instance instead() What I'm doing wrong? Ok I read about unbound functions and I was missing the decorator.. now when I define the search method like this: @classmethod def search(self, clause=[('id', '!=', None)], order=[('team', 'ASC')]): pass I get the error: File ../trytond-3.2.2/trytond/model/fields/one2many.py, line 98, in get targets = list(chain(*targets)) TypeError: 'NoneType' object is not iterable which I guess because there isn't bringing any records, but shouldn't just show an empty list? I have the feeling that I'm doing something really wrong. In the documentation doesn't say anything about defining that search function when defining many2many. Thanks! Mariano
Re: [tryton] model inheritance vs. class inheritance
On Tuesday, June 2, 2009 12:28:31 PM UTC-3, Cédric Krier wrote: On 02/06/09 08:11 -0700, dbrenck wrote: class Party(ModelSQL, ModelView): Class: Party(ModelSQL, ModelView) This class inherits party.party model and adds... _name = party.party dummy = fields.Function(get_dummy, type=one2many, relation=dummy.model, string=Dummy, context={'id': id} ) def get_dummy(...) This fails with a socket error (displayed by the client, but nothing to see serverside). If I change it to context={'id': 'id'} it works nicely - but, of cause, using the string 'id' instead of the partys id. id is a Python function so you have a socket error because you try to send to the server a function which is not marshable. You should use active_id Obviously model inheritance by _name is no real python/class inheritance. But how can I access the model-inherited fields at this point? In fact, it ends with a real Python inheritance. But I don't understand what you mean by 'access the model-inherited fields'? -- at which point exactly this happens? Im using gnuhealth which has PartyPatient and I just need to add a custom validator, to keep the code separated I created a new module installed it and create a new model which the only thing in common with PartyPatient (and Party) is the __name__ attribute. I can understand dbrenk's point and I still fail to understand how extending/inheriting models work. the validate method is not being called in my new class. I could achieve this by monkey patching, but afaik is better to avoid that, right? anyway here is my file, any help will be greatly appreciated: from trytond.model import ModelView, ModelSQL __all__ = ['CustomPartyPatient'] class CustomPartyPatient(ModelSQL, ModelView): 'Party' __name__ = 'party.party' @classmethod def __setup__(cls): super(CustomPartyPatient, cls).__setup__() @classmethod def validate(cls, parties): import pdb; pdb.set_trace() super(CustomPartyPatient, cls).validate(parties) print parties for party in parties: party.custom_check_person() def custom_check_person(self): if self.ref == someid: self.raise_user_error(no puede usar someid como id) def __register__(cls, module_name): super(CustomPartyPatient, cls).__register__(module_name) Saludos, Mariano.