# Can I override create method

**URL:** https://discuss.tryton.org/t/can-i-override-create-method/8486
**Category:** Developer
**Created:** [April 16, 2025, 5:45am UTC](https://discuss.tryton.org/t/can-i-override-create-method/8486 "2025-04-16T05:45:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bromoapp](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bromoapp](https://discuss.tryton.org/u/bromoapp)
#### Post date: [April 16, 2025, 5:45am UTC](https://discuss.tryton.org/t/can-i-override-create-method/8486/1 "2025-04-16T05:45:58Z")

</div>

Hi @oscarQ .. thank you.. I just test it and all messages printed in console.. by the way.. this next question may out of this topic:

I try to extend a base method for creating a new record in db like this:

```auto
    @classmethod
    def create(cls, record):
        """
        Override the save method to add custom logic before saving records.
        """
        logger.info(">>>>>>>>>>>>>>>> SAVING USER TIMESHEET", record)

```

And it throws error, maybe because I override the model’s create method.. my question:

How can I override this method to implement my new logic.. but still continue its function which is creating new record in table?  
Sorry for this newbie question

Bromo

---

<div class="post-metadata">

### Author: ![oscarQ](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/oscarq/32/413_2.png) [@oscarQ](https://discuss.tryton.org/u/oscarQ)
#### Post date: [April 16, 2025, 6:18am UTC](https://discuss.tryton.org/t/can-i-override-create-method/8486/2 "2025-04-16T06:18:58Z")

</div>

It would be helpful if you could share the specific error message you’re encountering; this would make it easier to understand the issue and assist you effectively.​

That said, the approach to overriding the create method depends on the version of Tryton you’re using. In recent versions, the method for customizing record creation has evolved.​

You can find more details in this discussion: 👉

> [@General hook for ModelStorage modification](https://discuss.tryton.org/t/general-hook-for-modelstorage-modification/8210):
>
> Rational Following [Generic support for cache fields](https://discuss.tryton.org/t/generic-support-for-cache-fields/8146), I found that we have 3 common pattern that requires to extend ModelStorage.create, ModelStorage.write and ModelStorage.delete which may be tricky to extend correctly (see [Verify access right only for RPC](https://discuss.tryton.org/t/verify-access-right-only-for-rpc/8123)): apply some modification to the values used for ModelStorage.create and ModelStorage.write (ex: standardize the format of email, put in uppercase the country code, set number from a sequence etc.) trigger an action on modified records (ex:…

Additionally, this commit illustrates the transition from the old method to the new approach: 👉

> **[Use ModelStorage hooks instead of extending create/write/delete (6c72b78d92d8)...](https://foss.heptapod.net/tryton/tryton/-/commit/6c72b78d92d8586b93a7bb33308317cee9c18052)**
>
> Business Software Modularity, scalability & security for your business Documentation Contribute

Let me know your Tryton version, and I can provide more specific guidance.​

Also, since this topic differs from your original question about console logging, it might be beneficial to start a new discussion thread. This approach keeps topics organized and makes it easier for others to follow and contribute.​

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [April 17, 2025, 6:19am UTC](https://discuss.tryton.org/t/can-i-override-create-method/8486/3 "2025-04-17T06:19:43Z")

</div>

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