On 2015-06-19 10:04, Mariano Ramon wrote:
>
>
> 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.
I still don't understand the problem but for me the design is wrong.
It should use the common pattern in Tryton of ordered list to define the
"main".
> 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__()
>
>
--
Cédric Krier - B2CK SPRL
Email/Jabber: [email protected]
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/