openspp-modules icon indicating copy to clipboard operation
openspp-modules copied to clipboard

Fix create function in farmer registry base

Open reichie020212 opened this issue 1 year ago • 1 comments

Fix the create function in the file spp_farmer_registry_base/models/farm.py since it breaks the function of res.partner model to create multiple records in one function. below is the sample code that will produce an error

self.env["res.partner"].create([{"name": "Test 1"}, {"name": "Test 2"}])

This is a major bug that will break other modules as well if this module is installed.

below is the create function that needs to fix

    @api.model_create_multi
    def create(self, vals):
        farm = super().create(vals)
        if farm.is_group:
            self.create_update_farmer(farm)
        elif not farm.is_group and farm.is_registrant:
            self.update_farmer(farm)

        return farm

reichie020212 avatar Sep 05 '24 08:09 reichie020212

Estimate Dev Time:

Optimistic: 4 hours Pessimistic: 12 hours

reichie020212 avatar Sep 13 '24 05:09 reichie020212

@anthonymarkQA and @reichie020212 , can you two test this together? primarily for @reichie020212 to check that the issue no longer exists and for @anthonymarkQA to verify that everything still working as expected

celinenilla avatar Oct 25 '24 01:10 celinenilla

Image Image @celinenilla @anthonymarkQA , Done testing the PR in my local and it is working as expected.

in the 1st screenshot, the fix is not yet deployed in my local that's why you can see that the error is showing. In the 2nd screenshot I already deployed the fix the error is not showing anymore

reichie020212 avatar Oct 28 '24 10:10 reichie020212

Additional tests: QA passed

Should not generate error when running the scheduled action manually in the farmer registry instance with the PR fix- pass image

Should generate error when running the scheduled action manually on a farmer registry isntance without the PR fix - pass image

anthonymarkQA avatar Oct 29 '24 08:10 anthonymarkQA